ldc-boutique-cnc/app/Models/OrderLine.php

68 lines
1.3 KiB
PHP
Raw Normal View History

2021-03-27 20:55:16 +01:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2022-10-03 17:13:44 +02:00
/**
* OrderLine
*
* @property string formated_total_ht Total ht in euro
* @property string formated_total_ttc Total ttc in euro
*
* @package App\Models
*/
2021-03-27 20:55:16 +01:00
class OrderLine extends Model
{
use HasFactory;
2022-09-03 16:56:16 +02:00
/**
* BelongsTo order relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2021-03-27 20:55:16 +01:00
public function order()
{
return $this->belongsTo(Order::class);
}
2022-09-03 16:56:16 +02:00
/**
* BelongsTo product relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2021-03-27 20:55:16 +01:00
public function product()
{
2021-03-29 15:10:07 +02:00
return $this->belongsTo(Product::class);
2021-03-27 20:55:16 +01:00
}
2022-10-03 17:13:44 +02:00
// * METHODS
2022-09-03 16:56:16 +02:00
/**
2022-10-03 17:13:44 +02:00
* Getter formated_total_ht
2022-09-03 16:56:16 +02:00
*
2022-10-03 17:13:44 +02:00
* @return string
*/
public function getFormattedTotalHtAttribute(): string
{
return sprintf(
'%s €',
number_format($this->total_ht / 100, 2, ',', ' ')
);
}
/**
* Getter formated_total_ttc
*
* @return string
2022-09-03 16:56:16 +02:00
*/
2022-10-03 17:13:44 +02:00
public function getFormattedTotalTtcAttribute(): string
{
2022-10-03 17:13:44 +02:00
return sprintf(
2022-09-03 16:56:16 +02:00
'%s €',
2022-10-03 17:13:44 +02:00
number_format($this->total_ttc / 100, 2, ',', ' ')
2022-09-03 16:56:16 +02:00
);
}
2021-03-27 20:55:16 +01:00
}