app/Http/Controllers/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(Request $request)
    {
        $preexist=user::where('email',$request->email)->count();
        if($preexist){
            return redirect()->back()->with(['error' => 'New already added.']);
        }
        $user =new User();
        $user->name=$request->name;
        $user->email=$request->email;
        $user->password=$request->password;
        $user->save();
        return redirect()->back()->with(['success' => 'New user added successfully.']);
    }
public function store ( Request $ request ) { $ preexist = user :: where ( 'email' , $ request -> email ) -> count ( ) ; if ( $ preexist ) { return redirect ( ) -> back ( ) -> with ( [ 'error' => 'New already added.' ] ) ; } $ user = new User ( ) ; $ user -> name = $ request -> name ; $ user -> email = $ request -> email ; $ user -> password = $ request -> password ; $ user -> save ( ) ; return redirect ( ) -> back ( ) -> with ( [ 'success' => 'New user added successfully.' ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .