/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StorePieceFormRequest $request) { $piece = Piece::create($request->all()); if ($request->file('file')) { $piece->update(['image' => $this->saveImage($request)]); } return redirect()->action('Admin\\PiecesController@show', [$piece->id]); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(PieceRequest $request) { $piece = Piece::create(['title' => $request->input('title')]); if ($request->hasFile('photo')) { $photoPath = PiecePhoto::storeFile($request->file('photo')); $image = $piece->photos()->create(['photo' => $photoPath, 'order' => 0]); } $piece->media()->sync($request->input('medium_list')); return redirect()->route('admin.pieces.show', $piece)->with('message', 'Piece created'); }