ldc-boutique-cnc/app/Models/OrderLine.php
2022-11-08 15:41:10 +01:00

67 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* OrderLine
*
* @property string formated_total_ht Total ht in euro
* @property string formated_total_ttc Total ttc in euro
*
* @package App\Models
*/
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);
}
// * METHODS
/**
* Getter formated_total_ht
*
* @return string
*/
public function getFormattedTotalHtAttribute(): string
{
return sprintf(
'%s €',
number_format($this->total_ht / 100, 2, ',', ' ')
);
}
/**
* Getter formated_total_ttc
*
* @return string
*/
public function getFormattedTotalTtcAttribute(): string
{
return sprintf(
'%s €',
number_format($this->total_ttc / 100, 2, ',', ' ')
);
}
}