Files
getgreen-backend/app/Models/OrderContract.php
2026-04-28 15:02:06 +05:00

60 lines
1.2 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Storage;
/**
* @package App\Models
* @property integer $id
* @property integer $order_id
* @property string $type
* @property string $path
*
* @property-read Order|BelongsTo $order
*
* @mother isContract(): bool
* @mother isMasterContract(): bool
*/
class OrderContract extends Model
{
use HasFactory;
const TYPE_CONTRACT = 'contract';
const TYPE_MASTER = 'master_contract';
protected $guarded = ['id'];
protected $casts = [
'order_id' => 'integer',
];
public function getPath()
{
if (!empty($this->path)) {
return Storage::url($this->path);
}
return null;
}
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
public function isContract(): bool
{
return $this->type === self::TYPE_CONTRACT;
}
public function isMasterContract(): bool
{
return $this->type === self::TYPE_MASTER;
}
}