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