app/Http/Controllers/Dashboard/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([
            'first_name' => 'required',
            'last_name' => 'required',
            'email' => 'required|unique:users',
            'image' => 'image',
            'password' => 'required|confirmed',
            'permissions' => 'required|min:1'
        ]);
        $request_data = $request->except(['password', 'password_confirmation', 'permissions', 'image']);
        $request_data['password'] = bcrypt($request->password);
        if ($request->image) {
            Image::make($request->image)
                ->resize(300, null, function ($constraint) {
                    $constraint->aspectRatio();
                })
                ->save(public_path('uploads/user_images/' . $request->image->hashName()));
            $request_data['image'] = $request->image->hashName();
        }
        $user = User::create($request_data);
        $user->attachRole('admin');
        $user->syncPermissions($request->permissions);
        session()->flash('success', __('site.added_successfully'));
        return redirect()->route('dashboard.users.index');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'first_name' => 'required' , 'last_name' => 'required' , 'email' => 'required|unique:users' , 'image' => 'image' , 'password' => 'required|confirmed' , 'permissions' => 'required|min:1' ] ) ; $ request_data = $ request -> except ( [ 'password' , 'password_confirmation' , 'permissions' , 'image' ] ) ; $ request_data [ 'password' ] = bcrypt ( $ request -> password ) ; if ( $ request -> image ) { Image :: make ( $ request -> image ) -> resize ( 300 , null , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) -> save ( public_path ( 'uploads/user_images/' . $ request -> image -> hashName ( ) ) ) ; $ request_data [ 'image' ] = $ request -> image -> hashName ( ) ; } $ user = User :: create ( $ request_data ) ; $ user -> attachRole ( 'admin' ) ; $ user -> syncPermissions ( $ request -> permissions ) ; session ( ) -> flash ( 'success' , __ ( 'site.added_successfully' ) ) ; return redirect ( ) -> route ( 'dashboard.users.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//end of if