ldc-gen-game-web/app/Models/FaqTheme.php

57 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
2023-11-30 11:10:02 +01:00
use App\Traits\Models\IsCachedAsCollection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* FaqTheme.
*
* @property string $question Question
* @property string $answer Answer
* @property-read \Illuminate\Support\Carbon $created_at Creation Date.
* @property-read \Illuminate\Support\Carbon $updated_at Last update Date.
*
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\FaqQuestion[] $questions
* Associated questions.
*/
class FaqTheme extends Model
{
2023-11-30 11:10:02 +01:00
use HasFactory;
use IsCachedAsCollection;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
/**
2023-11-30 11:10:02 +01:00
* Perform any actions required after the model boots.
*
2023-11-30 11:10:02 +01:00
* @return void
*/
2023-11-30 11:10:02 +01:00
protected static function booted()
{
static::created(fn () => self::removeCached());
static::updated(fn () => self::removeCached());
static::deleted(fn () => self::removeCached());
}
// * RELATIONS
2022-08-11 10:26:29 +02:00
/**
* Question relation
2023-08-22 09:18:39 +02:00
*
2022-08-11 10:26:29 +02:00
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function questions()
{
return $this->hasMany(FaqQuestion::class, 'theme_id');
}
}