ldc-legaulois/app/Models/SubRange.php
2021-09-23 13:38:15 +02:00

32 lines
787 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SubRange extends Model
{
protected $fillable = [
'name', 'picture_alt',
'back_link_url', 'back_link_text',
'title', 'subtitle', 'content'
];
protected static function booted()
{
static::creating(function (SubRange $subRange) {
$subRange->title = clean($subRange->title);
$subRange->content = clean($subRange->content);
});
static::updating(function (SubRange $subRange) {
$subRange->title = clean($subRange->title);
$subRange->content = clean($subRange->content);
});
}
public function ranges()
{
return $this->belongsToMany(Range::class, 'range_sub_range');
}
}