Commit 312e39db by Francisco Salazar

validate slug

parent 2155fd4e
......@@ -23,11 +23,17 @@ class RequestCategory extends FormRequest
*/
public function rules()
{
if ($this->get("_method") == "PUT" || $this->get("_method") == "PATCH"){
$slug = 'required|max:255|unique:entry_categories,slug,'.$this->route("category");
}else{
$slug = 'required|max:255|unique:entry_categories,slug';
}
return [
'name' => 'required|max:355',
'slug' => 'required|max:255',
'slug' => $slug,
'description'=> 'max:455',
'active' => 'required'
'active' => 'required',
'portada' => 'image'
];
}
}
\ No newline at end of file
......@@ -23,14 +23,21 @@ class RequestEntry extends FormRequest
*/
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' => 'required|max:255',
'slug' => $slug,
'status'=> 'required|numeric',
'tags'=> 'required|max:800',
'publication_date' => 'required',
'category_id' => 'required',
'body' => 'required'
'body' => 'required',
'cover' => 'image'
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment