コード例 #1
0
 /**
  * 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');
 }
コード例 #2
0
 /**
  * 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();
 }
コード例 #3
0
 /**
  * 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();
 }