You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
676 B
PHP
37 lines
676 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class Sale extends Model
|
|
{
|
|
protected $fillable = [
|
|
'code',
|
|
'date',
|
|
'customer_id',
|
|
'total',
|
|
'note'
|
|
];
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class)->withTrashed();
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(SaleItem::class);
|
|
}
|
|
|
|
public function formatedDate(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: function () {
|
|
return Carbon::parse($this->date)->format('d/m/Y');
|
|
}
|
|
);
|
|
}
|
|
}
|