lots of progress
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class GameList extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'slug',
|
||||
'description',
|
||||
'is_default'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($list) {
|
||||
$list->slug = Str::slug($list->name);
|
||||
});
|
||||
|
||||
static::updating(function ($list) {
|
||||
$list->slug = Str::slug($list->name);
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function games(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Game::class)->withTimestamps();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user