<?php namespace Onestartup\Shop\Requests; use Illuminate\Foundation\Http\FormRequest; class RequestSubCategory 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:product_subcategories_shop,slug,'.$this->route("subcategory"); }else{ $slug = 'required|max:255|unique:product_subcategories_shop,slug'; } return [ 'name' => 'required|max:355', 'slug' => $slug, 'description'=> 'max:455', 'active' => 'required|boolean', 'portada' => 'image' ]; } }