65 lines
1.1 KiB
PHP
65 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Uuid;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Source;
|
|
use App\Topic;
|
|
|
|
class Article extends Model
|
|
{
|
|
use Uuid;
|
|
|
|
/**
|
|
* The "type" of the auto-incrementing ID.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $keyType = 'string';
|
|
|
|
/**
|
|
* Indicates if the IDs are auto-incrementing.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public $incrementing = false;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dates = [
|
|
'published_date',
|
|
];
|
|
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'body' => 'array',
|
|
'meta' => 'array'
|
|
];
|
|
|
|
public function source()
|
|
{
|
|
return $this->belongsTo(Source::class);
|
|
}
|
|
|
|
public function topics()
|
|
{
|
|
return $this->belongsToMany(Topic::class)->withTimestamps();
|
|
}
|
|
}
|