mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 10:11:11 -05:00
43 lines
812 B
PHP
43 lines
812 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Designer extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'slug',
|
|
'bio',
|
|
];
|
|
|
|
/**
|
|
* Boot the model.
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($designer) {
|
|
if (empty($designer->slug)) {
|
|
$designer->slug = Str::slug($designer->name);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the rides designed by this designer.
|
|
*/
|
|
public function rides(): HasMany
|
|
{
|
|
return $this->hasMany(Ride::class);
|
|
}
|
|
} |