<?php namespace Onestartup\Blog\Requests; use Illuminate\Foundation\Http\FormRequest; class RequestEntry extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { if ($this->get("_method") == "PUT" || $this->get("_method") == "PATCH"){ $slug = 'required|max:255|unique:entries,slug,'.$this->route("entry"); }else{ $slug = 'required|max:255|unique:entries,slug'; } return [ 'title' => 'required|max:355', 'slug' => $slug, 'status'=> 'required|numeric', 'tags'=> 'required|max:800', 'publication_date' => 'required', 'category_id' => 'required', 'body' => 'required', 'cover' => 'image' ]; } }