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
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
/**
|
|
|
|
|
* @property string $name
|
|
|
|
|
*/
|
2022-08-30 13:21:07 +00:00
|
|
|
class Company extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-14 09:23:39 +00:00
|
|
|
* The attributes that are fillable.
|
2022-08-30 13:21:07 +00:00
|
|
|
*
|
2025-04-08 11:47:49 +02: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.
|
|
|
|
|
*
|
2025-04-08 11:47:49 +02:00
|
|
|
* @var list<string>
|
2023-08-14 17:48:26 +00:00
|
|
|
*/
|
|
|
|
|
protected $appends = [
|
|
|
|
|
'value'
|
|
|
|
|
];
|
|
|
|
|
|
2022-08-30 13:21:07 +00:00
|
|
|
/**
|
2025-04-08 11:47:49 +02:00
|
|
|
* HasMany Invoices.
|
2022-08-30 13:21:07 +00:00
|
|
|
*
|
2023-08-14 09:23:39 +00:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
2022-08-30 13:21:07 +00:00
|
|
|
*/
|
2025-04-08 11:47:49 +02:00
|
|
|
public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany
|
2022-08-30 13:21:07 +00:00
|
|
|
{
|
2023-08-14 09:23:39 +00:00
|
|
|
return $this->hasMany(Invoice::class);
|
2022-08-30 13:21:07 +00:00
|
|
|
}
|
2023-08-14 17:48:26 +00:00
|
|
|
|
|
|
|
|
/**
|
2025-04-08 11:47:49 +02:00
|
|
|
* Return value attribute for belongsto search component.
|
2023-08-14 17:48:26 +00:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
|
|
|
|
*/
|
2025-04-08 11:47:49 +02:00
|
|
|
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
|
|
|
}
|