23 lines
506 B
PHP
23 lines
506 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class ProductScreenshot extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = ['product_id', 'path', 'position'];
|
||
|
|
|
||
|
|
public function product(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Product::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function url(): Attribute
|
||
|
|
{
|
||
|
|
return Attribute::get(fn () => asset('storage/'.$this->path));
|
||
|
|
}
|
||
|
|
}
|