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)
    {
        $ret = ['success' => false, 'message' => 'Something went wrong!'];
        $data = $request->validate([
            'name'      => 'required',
            'email'     => ['required', 'unique:users'],
            'password'  => 'required'
        ]);
        $users = User::create($data);
        $users->password = Hash::make($request->password);
        if ($users->save()) {
            $ret = ['success' => true, 'message' => 'Data inserted successfully!'];
        }
        return response()->json($ret, 200);
    }
public function store ( Request $ request ) { $ ret = [ 'success' => false , 'message' => 'Something went wrong!' ] ; $ data = $ request -> validate ( [ 'name' => 'required' , 'email' => [ 'required' , 'unique:users' ] , 'password' => 'required' ] ) ; $ users = User :: create ( $ data ) ; $ users -> password = Hash :: make ( $ request -> password ) ; if ( $ users -> save ( ) ) { $ ret = [ 'success' => true , 'message' => 'Data inserted successfully!' ] ; } return response ( ) -> json ( $ ret , 200 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .