ldc-supportweb/app/Models/Company.php

56 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2022-08-30 13:21:07 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2023-08-14 17:48:26 +00:00
use Illuminate\Database\Eloquent\Casts\Attribute;
2022-08-30 13:21:07 +00:00
/**
* @property string $name
*/
2022-08-30 13:21:07 +00:00
class Company extends Model
{
use HasFactory;
/**
* The attributes that are fillable.
2022-08-30 13:21:07 +00:00
*
* @var list<string>
2022-08-30 13:21:07 +00:00
*/
protected $fillable = [
'name'
];
2023-08-14 17:48:26 +00:00
/**
* The accessors to append to the model's array form.
*
* @var list<string>
2023-08-14 17:48:26 +00:00
*/
protected $appends = [
'value'
];
2022-08-30 13:21:07 +00:00
/**
* HasMany Invoices.
2022-08-30 13:21:07 +00:00
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
2022-08-30 13:21:07 +00:00
*/
public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany
2022-08-30 13:21:07 +00:00
{
return $this->hasMany(Invoice::class);
2022-08-30 13:21:07 +00:00
}
2023-08-14 17:48:26 +00:00
/**
* Return value attribute for belongsto search component.
2023-08-14 17:48:26 +00:00
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function value(): \Illuminate\Database\Eloquent\Casts\Attribute
2023-08-14 17:48:26 +00:00
{
return new Attribute(
get: fn () => $this->id,
);
}
2022-08-30 13:21:07 +00:00
}