Initial commit: Import existing Laravel project
This commit is contained in:
35
app/Models/Attachment.php
Normal file
35
app/Models/Attachment.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user