1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 21:34:03 +00:00

Weekly Thread command

This commit is contained in:
Samuel Štancl 2021-10-17 21:36:41 +02:00
parent faefe1c45b
commit 3fe86bed08
3 changed files with 80 additions and 5 deletions

View file

@ -40,12 +40,15 @@ class Thread extends Model
public static function booted()
{
static::creating(fn (self $model) => $model->created_at ??= now());
static::creating(static function (self $model) {
$model->created_at ??= now();
$model->links ??= [];
});
}
public function tips(): HasMany
{
return $this->hasMany(Tip::class);
return $this->hasMany(Tip::class, 'thread_slug');
}
public function author(): BelongsTo