I want to get validation errors inside of blade component(php file), how to do that? in typical blade pages I could use @error, and get the message if there is corresponding validation error.
@Shivamyadav when you create a component e.g, make:component Test, it creates two files, one app/View/Components/Test.php, and resources/views/components/test.blade.php. I want to get the errors inside of app/View/Components/Test.php file, not resources/views/components/test.blade.php blade file
@amir5 you can get the ErrorBag inside a component which will return a MessageBag instance
$errors = $this->getErrorBag() // MessageBag
Then you can interrogate it in a similar way to the Blade templates
$errors->has('email') // Boolean; does the bag have any `email` messages
$errors->first('email') // first error message for `email` field
$errors->any() // Boolean; does the bag have any messages?
$errors->all() // array of all messages in the bag