Archived
1
0
Fork 0

Adding Spell Model

This commit is contained in:
Henrik Hautakoski 2021-07-07 16:18:01 +02:00
parent b7ccc4a657
commit 78d5d8d50e
3 changed files with 102 additions and 0 deletions

39
app/Models/Spell.php Normal file
View file

@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Spell extends Model
{
use HasFactory;
public $incrementing = false;
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'slug'
];
protected static function boot() {
parent::boot();
static::creating(function ($spell) {
$spell->slug = Str::slug($spell->name);
});
}
public function recipe()
{
return $this->hasOne(Recipe::class);
}
}