ldc-supportweb/app/Models/Company.php
2023-08-14 17:48:26 +00:00

55 lines
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 array
*/
protected $fillable = [
'name'
];
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = [
'value'
];
/**
* HasMany Invoices
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function invoices()
{
return $this->hasMany(Invoice::class);
}
/**
* Return value attribute for belongsto search component
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function value(): Attribute
{
return new Attribute(
get: fn () => $this->id,
);
}
}