2024-02-01 14:38:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
|
|
|
|
class Tag extends BaseModel
|
|
|
|
{
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
|
|
public function name(): Attribute
|
|
|
|
{
|
|
|
|
return Attribute::make(
|
|
|
|
get: fn ($value) => strtolower($value),
|
|
|
|
set: fn ($value) => strtolower($value)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
static public function ownedByCurrentTeam()
|
|
|
|
{
|
|
|
|
return Tag::whereTeamId(currentTeam()->id)->orderBy('name');
|
|
|
|
}
|
|
|
|
public function applications()
|
|
|
|
{
|
|
|
|
return $this->morphedByMany(Application::class, 'taggable');
|
|
|
|
}
|
2024-02-03 11:39:07 +00:00
|
|
|
public function services()
|
|
|
|
{
|
|
|
|
return $this->morphedByMany(Service::class, 'taggable');
|
2024-02-01 14:38:12 +00:00
|
|
|
}
|
|
|
|
}
|