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.
59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\OrderStatus;
|
|
use DateTimeInterface;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Order extends Model
|
|
{
|
|
use SoftDeletes, HasFactory;
|
|
|
|
protected $fillable = [
|
|
'customer_id',
|
|
'internal_po',
|
|
'customer_po',
|
|
'order_date',
|
|
'due_date',
|
|
'status',
|
|
'rush',
|
|
'new_art',
|
|
'digitizing',
|
|
'repeat',
|
|
'purchased_garments',
|
|
'customer_supplied_file',
|
|
'notes',
|
|
];
|
|
|
|
protected $appends = [
|
|
'active_status'
|
|
];
|
|
|
|
public function getActiveStatus(): bool
|
|
{
|
|
if ($this->status === OrderStatus::COMPLETED || $this->status === OrderStatus::CANCELLED) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
protected function serializeDate(DateTimeInterface $date): string
|
|
{
|
|
return $date->format('Y-m-d');
|
|
}
|
|
|
|
protected $casts = [
|
|
'status' => OrderStatus::class
|
|
];
|
|
}
|