app/Http/Requests/ArticleRequest.php
/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
Get the validation rules that apply to the request.
@return array
Get the validation rules that apply to the request . @return array
public function rules()
    {
        $article= Article::find($this->article);
        switch($this->method())
        {
            case 'GET':
            case 'DELETE':
            {
                return [];
            }
            case 'POST':
            {
                return [
                    'title'      => 'min:10|required|unique:articles',
                    'category_id'=> 'required',
                    'preview'    => 'min:10|required',
                    'content'    => 'min:10|required',
                    'tags'       => 'required|min:1',
                    'image'      => 'required|image'
                ];
            }
            case 'PUT':
            case 'PATCH':
            {
                return [
                   'title'      => 'min:10|required|unique:articles,title,'.$article->id,
                   'category_id'=> 'required',
                   'preview'    => 'min:10|required',
                   'content'    => 'min:10|required',
                   'tags'       => 'required|min:1',
                   'statu_id'  => 'required'
                ];
            }
            default:break;
        }
    }
public function rules ( ) { $ article = Article :: find ( $ this -> article ) ; switch ( $ this -> method ( ) ) { case 'GET' : case 'DELETE' : { return [ ] ; } case 'POST' : { return [ 'title' => 'min:10|required|unique:articles' , 'category_id' => 'required' , 'preview' => 'min:10|required' , 'content' => 'min:10|required' , 'tags' => 'required|min:1' , 'image' => 'required|image' ] ; } case 'PUT' : case 'PATCH' : { return [ 'title' => 'min:10|required|unique:articles,title,' . $ article -> id , 'category_id' => 'required' , 'preview' => 'min:10|required' , 'content' => 'min:10|required' , 'tags' => 'required|min:1' , 'statu_id' => 'required' ] ; } default : break ; } }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .