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
|
|
|
/**
|
2026-06-24 16:25:58 +02:00
|
|
|
* @property int $id
|
2023-08-14 09:23:39 +00:00
|
|
|
* @property string $name
|
2026-06-24 16:25:58 +02:00
|
|
|
* @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
|
2023-08-14 09:23:39 +00:00
|
|
|
*/
|
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
|
|
|
*
|
|
|
|
|
* @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
|
|
|
/**
|
2023-08-14 09:23:39 +00: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
|
|
|
*/
|
2023-08-14 09:23:39 +00:00
|
|
|
public function invoices()
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
}
|