Let me give a brief about what I am intending to do:
I am using Laravel 5.6
I am using Form Validation Requests:
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class GeneralSettingValidation 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()
{
return [
'company_name' => 'required|max:10'
];
}
}
Here is the concerned method from controller:
public function store(GeneralSettingValidation $request) {
//do something
}
In my blade view, I am getting an alert on top of the page containing all the validation error messages even though I am not referring to $errors session data in my view.
Even if I refer to $errors session data, I get error messages per form field but also the alert on top of the page.
I do not want the alert having validation errors on top of the page (No need for that).
I want validation error messages per form field only.
Inside my blade view elements, i want to utilize the $errors->first('company_name') ? "has-error" : "", for example inside this element
I want validation error messages per form field only.
That is what is showed you. You can use the name of the field to get the validation error message using $errors->first('company_name') where $errors is a variable that is available to every view.