mirror of
https://github.com/flarum/core.git
synced 2025-07-24 18:21:33 +02:00
Extract model validation into a trait
Also use Laravel’s ValidationException rather than our own custom one
This commit is contained in:
@@ -12,19 +12,28 @@ use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Support\EventGenerator;
|
||||
use Flarum\Core\Support\Locked;
|
||||
use Flarum\Core\Support\VisibleScope;
|
||||
use Flarum\Core\Support\ValidatesBeforeSave;
|
||||
|
||||
class Discussion extends Model
|
||||
{
|
||||
use EventGenerator;
|
||||
use Locked;
|
||||
use VisibleScope;
|
||||
use ValidatesBeforeSave;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'discussions';
|
||||
|
||||
/**
|
||||
* The validation rules for this model.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $rules = [
|
||||
protected $rules = [
|
||||
'title' => 'required',
|
||||
'start_time' => 'required|date',
|
||||
'comments_count' => 'integer',
|
||||
@@ -37,13 +46,6 @@ class Discussion extends Model
|
||||
'last_post_number' => 'integer'
|
||||
];
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'discussions';
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
|
Reference in New Issue
Block a user