Ejemplo n.º 1
0
 /**
  * Get the zinc content.
  *
  * @param Request $request
  * @param int $year
  * @param int $month
  *
  * @return \Illuminate\View\View
  */
 public function show(Request $request, $year, $month)
 {
     $zinc = Zinc::with(['media'])->where('year', $year)->where('month', $month)->firstOrFail();
     if (!$zinc->getAttribute('published') && is_null($request->user())) {
         throw new NotFoundHttpException();
     }
     return view('zinc.show', compact('zinc'));
 }
Ejemplo n.º 2
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $rules = ['year' => 'required|in:' . implode(',', Zinc::year()), 'month' => 'required|in:' . implode(',', Zinc::month()) . '|unique:zinc,month,NULL,id,year,' . $this->input('year'), 'topic' => 'required|string|max:255', 'published' => 'boolean', 'image' => 'sometimes|required|array', 'image.*' => 'sometimes|required|image'];
     if ($this->isMethod('PATCH')) {
         $rules['month'] = str_replace('NULL', $this->route('manage'), $rules['month']);
     }
     return $rules;
 }
Ejemplo n.º 3
0
 /**
  * Delete the specific zinc.
  *
  * @param int $id
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @throws \Exception
  */
 public function destroy($id)
 {
     Zinc::findOrFail($id)->delete();
     return $this->ok();
 }