28 lines
596 B
PHP
28 lines
596 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class OrderLine extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
// Relations
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
// Formattages
|
|
public function getFormattedTotalTtcAttribute()
|
|
{
|
|
return $this->attributes['formattedTotalTtc'] = sprintf('%s €', number_format($this->attributes['total_ttc'], 2, ',', ' '));
|
|
}
|
|
}
|