ldc-supportweb/app/Models/Company.php

63 lines
1.4 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 int $id
* @property string $name
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read mixed $value
* @method static \Database\Factories\CompanyFactory factory($count = null, $state = [])
* @mixin \Eloquent
*/
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 array
*/
protected $fillable = [
'name'
];
2023-08-14 17:48:26 +00:00
/**
* The accessors to append to the model's array form.
*
* @var array
*/
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()
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
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function value(): Attribute
{
return new Attribute(
get: fn () => $this->id,
);
}
2022-08-30 13:21:07 +00:00
}