tsungsoft/error-message is a Laravel package for a laravel nova field..
It currently has 2 GitHub stars and 29.374 downloads on Packagist (latest version 0.0.3).
Install it with composer require tsungsoft/error-message.
Discover more Laravel packages by tsungsoft
or browse all Laravel packages to compare alternatives.
Last updated
When throwing exception will display our actual message but only works on local environment and debug is true. if using this on production environment and debug is false it will always showing Server Error
but on the other hand using ValidationException, it will show "There was a problem submitting the form." and there is no way to show our message to the user ( as far as i know).
using this will ada new field on the form but only showing it when have error message.
using packagist
composer require tsungsoft/error-message
using github repository add this on composer.json
"require": {
"tsungsoft/error-message": "*"
}
"repositories": [
{
"type": "vcs",
"url": "https://github.com/anditsung/laravel-nova-error-message"
}
],
on Nova Resource
use Tsungsoft\ErrorMessage\ErrorMessage;
...
public function fields(Request $request)
{
return [
...
ErrorMessage::make('Error'), // 'Error' -> must have the same value on ValidationException
...
];
}
...
on Model
...
private static function validationError($message)
{
$messageBag = new MessageBag;
$messageBag->add('error', __($message)); // 'error' -> must have the same value when creating the field on nova resource
throw ValidationException::withMessages($messageBag->getMessages());
}
protected static function boot()
{
parent::boot();
static::creating(function($user) {
...
self::validationError("You have an error");
...
});
static::updating(function($user) {
...
self::validationError("You have an error");
...
});
}
...

