31 lines
749 B
PHP
31 lines
749 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use App\Constant\Constant;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class PostImage extends Model
|
||
|
|
{
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'post_id',
|
||
|
|
'image_name',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getImageNameAttribute($value): string
|
||
|
|
{
|
||
|
|
if (!empty($value)) {
|
||
|
|
// $imagePath = Constant::POST_IMAGE_UPLOAD_PATH . '/' . $value;
|
||
|
|
// return getImage($value, Constant::POST_IMAGE_UPLOAD_PATH, '');
|
||
|
|
return asset('storage/app/public/images/posts/' . $value);
|
||
|
|
}
|
||
|
|
return asset('public/images/misc/placeholder.png');; // Need to set default image
|
||
|
|
}
|
||
|
|
}
|