1
0
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:
Toby Zerner
2015-07-05 12:25:08 +09:30
parent 04501545e3
commit 53e269fd89
11 changed files with 193 additions and 234 deletions

View File

@@ -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.
*