adrema/app/Activity.php

54 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App;
2023-02-23 22:43:13 +01:00
use App\Http\Views\ActivityFilterScope;
2021-08-22 19:31:20 +02:00
use App\Nami\HasNamiField;
2022-02-12 01:06:44 +01:00
use Cviebrock\EloquentSluggable\Sluggable;
2023-02-23 22:43:13 +01:00
use Illuminate\Database\Eloquent\Builder;
2022-03-06 02:56:03 +01:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2020-04-12 00:26:44 +02:00
use Illuminate\Database\Eloquent\Model;
2021-07-15 20:56:53 +02:00
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
2020-04-12 00:26:44 +02:00
class Activity extends Model
{
2022-03-06 02:56:03 +01:00
use HasFactory;
2021-08-22 19:31:20 +02:00
use HasNamiField;
2022-02-12 01:06:44 +01:00
use Sluggable;
2021-08-22 19:31:20 +02:00
public $fillable = ['is_try', 'has_efz', 'is_member', 'name', 'is_filterable', 'nami_id'];
2020-04-12 00:26:44 +02:00
public $timestamps = false;
public $casts = [
2022-03-11 20:19:17 +01:00
'nami_id' => 'integer',
2023-03-04 12:09:25 +01:00
'is_filterable' => 'boolean',
2020-04-12 00:26:44 +02:00
];
2022-02-12 01:06:44 +01:00
public function sluggable(): array
{
return [
'slug' => [
'source' => 'name',
],
];
}
2023-02-23 22:43:13 +01:00
/**
* @param Builder<self> $query
*
* @return Builder<self>
*/
public function scopeWithFilter(Builder $query, ActivityFilterScope $filter): Builder
{
return $filter->apply($query);
}
2023-02-17 18:57:11 +01:00
/**
* @return BelongsToMany<Subactivity>
*/
2022-03-11 20:19:17 +01:00
public function subactivities(): BelongsToMany
{
2021-06-23 01:05:17 +02:00
return $this->belongsToMany(Subactivity::class);
2020-04-12 00:26:44 +02:00
}
}