ldc-flucollector/app/Models/ArcadiaBrand.php
Jérémy Munsch c0c1608ad5
Api calls ok
2023-10-02 12:26:41 +02:00

118 lines
2.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Rennokki\QueryCache\Traits\QueryCacheable;
/**
* @property-read integer $id The arcadia brand id.
* @property-read string $label The arcadia brand name.
*
* @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\Service> $services
* The Services for the ArcadiaBrand.
* @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\XmlInco> $xmlIncos
* The XmlIncos for the ArcadiaBrand.
* @package App\Models
*/
class ArcadiaBrand extends Model
{
use HasFactory;
use QueryCacheable;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var boolean
*/
public $incrementing = false;
/**
* The timeout cache for this model
*
* @var integer
*/
protected $cacheFor = 0;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'id',
'label'
];
/**
* ArcadiaBrand
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$this->cacheFor = config('api.arcadiaBrandsDBCache') * 60;
parent::__construct($attributes);
}
/**
* Set the base cache tags that will be present
* on all queries.
*
* ! This is used to flush caching
*
* @return array
*/
protected function getCacheBaseTags(): array
{
return [
'incollector_arcadia_brands',
];
}
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
static::created(function () {
// * Flush Eloquent cache.
self::flushQueryCache();
});
static::updated(function () {
// * Flush Eloquent cache.
self::flushQueryCache();
});
static::deleted(function () {
// * Flush Eloquent cache.
self::flushQueryCache();
});
}
// * RELATIONS
/**
* Get all of the Services for the ArcadiaBrand
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function services(): HasMany
{
return $this->hasMany(Service::class);
}
/**
* Get all of the xmlIncos for the ArcadiaBrand
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function xmlIncos(): HasMany
{
return $this->hasMany(XmlInco::class);
}
}