app/Http/Controllers/UsersController.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)
    {
        $request->validate([
            'name' => 'required',
            'sirname' => 'required',
            'email' => 'required',
            'password'=> 'required|min:10'
        ]);
            $newUser = new User();
            $newUser->name = $request->name;
            $newUser->sirname = $request->sirname;
            $newUser->email = $request->email;
            $hashedPassword = Hash::make($request->password);
            $newUser->password =  $hashedPassword;
            $newUser -> save();
            return $newUser;
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required' , 'sirname' => 'required' , 'email' => 'required' , 'password' => 'required|min:10' ] ) ; $ newUser = new User ( ) ; $ newUser -> name = $ request -> name ; $ newUser -> sirname = $ request -> sirname ; $ newUser -> email = $ request -> email ; $ hashedPassword = Hash :: make ( $ request -> password ) ; $ newUser -> password = $ hashedPassword ; $ newUser -> save ( ) ; return $ newUser ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//validating the inputs on the server //create new user object