app/Http/Controllers/Admin/userController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(UserValidator $request)
    {
        $user = new User([
         'email'=>$request->email,
         'role'=>$request->role,
         'name'=>$request->name,
         'password'=>Hash::make($request->password),
         'status'=>$request->status
        ]); 
$users=$user->save();
$notification = User::where('role', '=', '1')->get();
$thread = [
    'added_by' => auth()->user()->name,
    'added_to' => $request->name,
];
foreach ($notification as $notification)
        {
        $notification->notify(new UserNotify($thread));
        }  
        Mail::to($user->email)->send(new UserCreateMail());
        if($users){
        return redirect()->route('user.index')->with('success', 'User Created Successfully');
    }else{
        return redirect()->back('')->with('error', 'Oops!! some error occured');
    }
}
public function store ( UserValidator $ request ) { $ user = new User ( [ 'email' => $ request -> email , 'role' => $ request -> role , 'name' => $ request -> name , 'password' => Hash :: make ( $ request -> password ) , 'status' => $ request -> status ] ) ; $ users = $ user -> save ( ) ; $ notification = User :: where ( 'role' , '=' , '1' ) -> get ( ) ; $ thread = [ 'added_by' => auth ( ) -> user ( ) -> name , 'added_to' => $ request -> name , ] ; foreach ( $ notification as $ notification ) { $ notification -> notify ( new UserNotify ( $ thread ) ) ; } Mail :: to ( $ user -> email ) -> send ( new UserCreateMail ( ) ) ; if ( $ users ) { return redirect ( ) -> route ( 'user.index' ) -> with ( 'success' , 'User Created Successfully' ) ; } else { return redirect ( ) -> back ( '' ) -> with ( 'error' , 'Oops!! some error occured' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .