23 lines
454 B
PHP
23 lines
454 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Image extends Model
|
|
{
|
|
protected $fillable = ['user_id', 'path', 'title', 'description','type',];
|
|
|
|
public function user() {
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function getUrlAttribute()
|
|
{
|
|
return asset('storage/' . $this->path);
|
|
}
|
|
|
|
// Make sure the URL is included when serializing
|
|
protected $appends = ['url'];
|
|
}
|