/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($zip, $title) { $trinket = Trinket::withZipTitle($zip, $title); if ($trinket) { return view('trinkets.show', compact('trinket')); } return view('trinkets.not-found'); }
/** * Apply a photo to the referenced Trinket. * * @param string $zip * @param string $title * @param AddTrinketPhotoRequest $request */ public function store($zip, $title, AddTrinketPhotoRequest $request) { // Find the Trinket and add the photo $trinket = Trinket::withZipTitle($zip, $title); $photo = $request->file('trinketPhoto'); // Create photo instance from a file upload (new AddPhotoToTrinket($trinket, $photo))->save(); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return Trinket::where(['zip' => $this->zip, 'title' => $this->title, 'user_id' => $this->user()->id])->exists(); }