app/Http/Controllers/Backsite/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(StoreUserRequest $request)
    {
        $data = $request->all();
        $data['password'] = Hash::make($data['email']);
        $user = User::create($data);
        $user->role()->sync($request->input('role', []));
        $detail_user = new DetailUser;
        $detail_user->user_id = $user['id'];
        $detail_user->type_user_id = $request['type_user_id'];
        $detail_user->save();
        alert()->success('Success Message', 'Successfully added new user');
        return redirect()->route('backsite.user.index');
    }
public function store ( StoreUserRequest $ request ) { $ data = $ request -> all ( ) ; $ data [ 'password' ] = Hash :: make ( $ data [ 'email' ] ) ; $ user = User :: create ( $ data ) ; $ user -> role ( ) -> sync ( $ request -> input ( 'role' , [ ] ) ) ; $ detail_user = new DetailUser ; $ detail_user -> user_id = $ user [ 'id' ] ; $ detail_user -> type_user_id = $ request [ 'type_user_id' ] ; $ detail_user -> save ( ) ; alert ( ) -> success ( 'Success Message' , 'Successfully added new user' ) ; return redirect ( ) -> route ( 'backsite.user.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// get all request from frontsite // hash password // store to database // sync role by users select // save to detail user , to set type user