app/Http/Controllers/AdminUsersController.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(CreateUserRequest $request)
    {
        if(trim($request->password) == ''){
            $input = $request->except('password');
        } else {
            $input = $request->all();
        }
        $input = $request->all();
        if($file = $request->file('photo_id')){
            $name = time() . $file->getClientOriginalName();
            $photo = Photo::create(['file' => $name ]);
            $file->move('images', $name);
            $input['photo_id'] = $photo->id;
        }
        $input['password'] = bcrypt($request->password);
        User::create($input);
        Session::flash('created_user', 'The user has been created');
        return redirect('/admin/users');
    }
public function store ( CreateUserRequest $ request ) { if ( trim ( $ request -> password ) == '' ) { $ input = $ request -> except ( 'password' ) ; } else { $ input = $ request -> all ( ) ; } $ input = $ request -> all ( ) ; if ( $ file = $ request -> file ( 'photo_id' ) ) { $ name = time ( ) . $ file -> getClientOriginalName ( ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ file -> move ( 'images' , $ name ) ; $ input [ 'photo_id' ] = $ photo -> id ; } $ input [ 'password' ] = bcrypt ( $ request -> password ) ; User :: create ( $ input ) ; Session :: flash ( 'created_user' , 'The user has been created' ) ; return redirect ( '/admin/users' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// NEW STUFF - file persistance /*
            PEEP THE TECHNIQUE FOR: 
            1) GETTING FILES OUT OF $request, 
            2) MOVING THEM INTO SEPERATE FOLDER
            3) PERSISTING THEM INTO THE DB
            4) GETTING THE ID FROM PERSISTED FILE AND USE IT AS FOREGIN KEY
            
        */