2015-09-09 09:28:47 +00:00
|
|
|
<?php namespace Database\Tester\Models;
|
|
|
|
|
|
|
|
|
|
use Model;
|
|
|
|
|
|
|
|
|
|
class Post extends Model
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string The database table used by the model.
|
|
|
|
|
*/
|
|
|
|
|
public $table = 'database_tester_posts';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Guarded fields
|
|
|
|
|
*/
|
|
|
|
|
protected $guarded = ['*'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Fillable fields
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Relations
|
|
|
|
|
*/
|
|
|
|
|
public $belongsTo = [
|
|
|
|
|
'author' => 'Database\Tester\Models\Author',
|
|
|
|
|
];
|
|
|
|
|
|
2015-09-18 19:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SluggablePost extends Post
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
use \October\Rain\Database\Traits\Sluggable;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Guarded fields
|
|
|
|
|
*/
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array List of attributes to automatically generate unique URL names (slugs) for.
|
|
|
|
|
*/
|
|
|
|
|
protected $slugs = [
|
|
|
|
|
'slug' => 'title'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RevisionablePost extends Post
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
use \October\Rain\Database\Traits\Revisionable;
|
2016-01-13 09:11:39 +00:00
|
|
|
use \October\Rain\Database\Traits\SoftDelete;
|
2015-09-18 19:36:58 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Guarded fields
|
|
|
|
|
*/
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Dates
|
|
|
|
|
*/
|
|
|
|
|
protected $dates = ['published_at', 'deleted_at'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Monitor these attributes for changes.
|
|
|
|
|
*/
|
|
|
|
|
protected $revisionable = [
|
|
|
|
|
'title',
|
|
|
|
|
'slug',
|
|
|
|
|
'description',
|
|
|
|
|
'is_published',
|
|
|
|
|
'published_at',
|
|
|
|
|
'deleted_at'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var int Maximum number of revision records to keep.
|
|
|
|
|
*/
|
|
|
|
|
public $revisionableLimit = 8;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array Relations
|
|
|
|
|
*/
|
|
|
|
|
public $morphMany = [
|
|
|
|
|
'revision_history' => ['System\Models\Revision', 'name' => 'revisionable']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The user who made the revision.
|
|
|
|
|
*/
|
|
|
|
|
public function getRevisionableUser()
|
|
|
|
|
{
|
|
|
|
|
return 7;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 09:28:47 +00:00
|
|
|
}
|