app/Http/Requests/CompanyRequest.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()
    {
        $rules = [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:companies',
            'address' => 'string|max:255',
            'website' => 'string|max:255',
        ];
        if ($this->method() == 'PUT') {
            $rules['email'] = 'required|string|email|max:255|unique:companies,email,' . $this->company->id;
        }
        return $rules;
    }
public function rules ( ) { $ rules = [ 'name' => 'required|string|max:255' , 'email' => 'required|string|email|max:255|unique:companies' , 'address' => 'string|max:255' , 'website' => 'string|max:255' , ] ; if ( $ this -> method ( ) == 'PUT' ) { $ rules [ 'email' ] = 'required|string|email|max:255|unique:companies,email,' . $ this -> company -> id ; } return $ rules ; }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .