2022-10-02 18:38:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2023-03-14 11:01:36 +00:00
|
|
|
use Spatie\Sluggable\HasSlug;
|
|
|
|
use Spatie\Sluggable\SlugOptions;
|
2022-10-02 18:38:41 +00:00
|
|
|
use Stevebauman\Purify\Facades\Purify;
|
|
|
|
|
|
|
|
class Template extends Model
|
|
|
|
{
|
2023-03-14 11:01:36 +00:00
|
|
|
use HasFactory, HasSlug;
|
2022-10-02 18:38:41 +00:00
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'slug',
|
|
|
|
'description',
|
|
|
|
'image_url',
|
|
|
|
'structure',
|
|
|
|
'questions',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'structure' => 'array',
|
|
|
|
'questions' => 'array',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function setDescriptionAttribute($value)
|
|
|
|
{
|
|
|
|
// Strip out unwanted html
|
|
|
|
$this->attributes['description'] = Purify::clean($value);
|
|
|
|
}
|
2023-03-14 11:01:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Config/options
|
|
|
|
*/
|
|
|
|
public function getSlugOptions(): SlugOptions
|
|
|
|
{
|
|
|
|
return SlugOptions::create()
|
|
|
|
->doNotGenerateSlugsOnUpdate()
|
|
|
|
->generateSlugsFrom('name')
|
|
|
|
->saveSlugsTo('slug');
|
|
|
|
}
|
2022-10-02 18:38:41 +00:00
|
|
|
}
|