36 lines
627 B
PHP
36 lines
627 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class Attachment extends Model
|
|
{
|
|
protected $fillable = [
|
|
'order_id',
|
|
'file_path',
|
|
'file_name',
|
|
'file_type',
|
|
];
|
|
|
|
protected $appends = ['url'];
|
|
|
|
/**
|
|
* Relation avec la commande.
|
|
*/
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
/**
|
|
* Accesseur pour obtenir l'URL de téléchargement sécurisée.
|
|
*/
|
|
public function getUrlAttribute()
|
|
{
|
|
return route('attachments.show', $this->id);
|
|
}
|
|
}
|