app/Http/Requests/PostRequest.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()
    {
        $post = $this->route()->parameter('post');
        $rules = [
            'name' => 'required',
            'slug' => 'required|unique:posts',
            'status' => 'required|in:1,2',
            'file' => 'image' 
        ];
        if($post){
            $rules['slug'] =   'required|unique:posts,slug,' . $post->id;
        }
        if($this->status == 2){
            $rules = array_merge($rules, [
                'category_id' => 'required',
                'tags' => 'required',
                'extract' => 'required',
                'body' => 'required'
            ]);
        }
        return $rules;
    }
public function rules ( ) { $ post = $ this -> route ( ) -> parameter ( 'post' ) ; $ rules = [ 'name' => 'required' , 'slug' => 'required|unique:posts' , 'status' => 'required|in:1,2' , 'file' => 'image' ] ; if ( $ post ) { $ rules [ 'slug' ] = 'required|unique:posts,slug,' . $ post -> id ; } if ( $ this -> status == 2 ) { $ rules = array_merge ( $ rules , [ 'category_id' => 'required' , 'tags' => 'required' , 'extract' => 'required' , 'body' => 'required' ] ) ; } return $ rules ; }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .
/*   return [
            //
        ]; */ //variable que recupera la información del post //metodo php que fuciona dos arrays