ldc-supportweb/app/Models/Company.php
2025-04-23 12:24:31 +02:00

55 lines
1.1 KiB
PHP

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