36 lines
656 B
PHP
36 lines
656 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class Post extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'custom_post_type_id',
|
||
|
|
'user_id',
|
||
|
|
'title',
|
||
|
|
'slug',
|
||
|
|
'content',
|
||
|
|
'custom_fields_data',
|
||
|
|
'status',
|
||
|
|
'published_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'content' => 'array',
|
||
|
|
'custom_fields_data' => 'array',
|
||
|
|
'published_at' => 'datetime',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function customPostType()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(CustomPostType::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function author()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'user_id');
|
||
|
|
}
|
||
|
|
}
|