52 lines
953 B
PHP
52 lines
953 B
PHP
<?php
|
|
|
|
namespace Modules\Post\app\Models;
|
|
|
|
use Modules\Page\app\Models\Page;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Post extends Model
|
|
{
|
|
const FILE_PATH = 'uploads/posts/';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'slug',
|
|
'image',
|
|
'title',
|
|
'short_detail',
|
|
'full_detail',
|
|
'page_id',
|
|
'sidebar_flag',
|
|
'navbar_flag',
|
|
'order',
|
|
'meta_title',
|
|
'meta_description',
|
|
'meta_keywords'
|
|
];
|
|
|
|
/**
|
|
* Relation with page
|
|
*/
|
|
public function page()
|
|
{
|
|
return $this->belongsTo(Page::class, 'page_id');
|
|
}
|
|
|
|
/**
|
|
* Function to get full image path
|
|
*/
|
|
public function getFullImageAttribute()
|
|
{
|
|
$result = null;
|
|
|
|
if($this->image) {
|
|
$result = asset('storage/' . Self::FILE_PATH . $this->image);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|