56 lines
961 B
PHP
56 lines
961 B
PHP
<?php
|
|
|
|
namespace Modules\Page\app\Models;
|
|
|
|
use Modules\Post\app\Models\Post;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Page extends Model
|
|
{
|
|
// use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'title',
|
|
'slug',
|
|
'summary',
|
|
'description',
|
|
'display_order',
|
|
'code',
|
|
'status',
|
|
'image',
|
|
'image_path',
|
|
];
|
|
|
|
public function pageMeta()
|
|
{
|
|
return $this->hasOne(PageMeta::class, 'page_id');
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function posts()
|
|
{
|
|
return $this->hasMany(Post::class);
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function getFullImageAttribute()
|
|
{
|
|
$result = null;
|
|
|
|
if($this->image_path) {
|
|
$result = asset('storage/uploads/' . $this->image_path);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|