Adding Spell Model
This commit is contained in:
parent
b7ccc4a657
commit
78d5d8d50e
3 changed files with 102 additions and 0 deletions
39
app/Models/Spell.php
Normal file
39
app/Models/Spell.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in a new issue