app/Http/Controllers/Api/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)
    {
        $request->validate([
            'email'=> 'required|email|unique:users,email',
            'password'=> 'required|min:6',
            'name'=> 'required|min:3|string',
            'image'=> 'string',
        ]);
        $user = User::create([
            'name' => $request['name'],
            'email' => $request['email'],
            'password' => Hash::make(($request['password'])) ,
            'image' => $request['image'],
        ]);
        return response([
            'user' => $user,
            'token' => $user->createToken('secret')->plainTextToken
        ], 201);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'email' => 'required|email|unique:users,email' , 'password' => 'required|min:6' , 'name' => 'required|min:3|string' , 'image' => 'string' , ] ) ; $ user = User :: create ( [ 'name' => $ request [ 'name' ] , 'email' => $ request [ 'email' ] , 'password' => Hash :: make ( ( $ request [ 'password' ] ) ) , 'image' => $ request [ 'image' ] , ] ) ; return response ( [ 'user' => $ user , 'token' => $ user -> createToken ( 'secret' ) -> plainTextToken ] , 201 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//