ldc-flucollector/app/Models/ArcadiaBrand.php
Jérémy Munsch 656120f042
TMP
- Arcadia Xml Jobs WIP
- Api WIP
2022-04-11 12:41:44 +02:00

90 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Rennokki\QueryCache\Traits\QueryCacheable;
class ArcadiaBrand extends Model
{
use HasFactory;
use QueryCacheable;
/**
* The timeout cache for this model
*
* @var integer
*/
protected $cacheFor = 0;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'arcadia_id',
'libelle'
];
/**
* 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
/**
* Service belongsToMany relation
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function services()
{
return $this->belongsToMany(Service::class);
}
}