app/Http/Controllers/AdminPicturesController.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)
    {
        $input = $request->all();
        if($file = $request->file('photo_id')){
            $name = time() . '_' .$file->getClientOriginalName();
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['photo_id'] = $photo->id;
            if($input['cropped_photo_id']){ 
                $name = time() . '_cropped_' .$file->getClientOriginalName();
                Image::make($input['cropped_photo_id'])->save('images/'.$name);
                $photo_cropped = Photo::create(['file'=>$name]);
                $input['cropped_photo_id'] = $photo_cropped->id;
            }
        }
        Picture::create($input);
        return redirect('/admin/pictures/create');
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; if ( $ file = $ request -> file ( 'photo_id' ) ) { $ name = time ( ) . '_' . $ file -> getClientOriginalName ( ) ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'photo_id' ] = $ photo -> id ; if ( $ input [ 'cropped_photo_id' ] ) { $ name = time ( ) . '_cropped_' . $ file -> getClientOriginalName ( ) ; Image :: make ( $ input [ 'cropped_photo_id' ] ) -> save ( 'images/' . $ name ) ; $ photo_cropped = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'cropped_photo_id' ] = $ photo_cropped -> id ; } } Picture :: create ( $ input ) ; return redirect ( '/admin/pictures/create' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//