firstcommit
This commit is contained in:
0
Modules/Post/app/Models/.gitkeep
Normal file
0
Modules/Post/app/Models/.gitkeep
Normal file
51
Modules/Post/app/Models/Post.php
Normal file
51
Modules/Post/app/Models/Post.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user