v1.0.0
This commit is contained in:
40
src/app/Models/Subcategory.php
Normal file
40
src/app/Models/Subcategory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['category_id', 'name', 'description', 'default_priority_key'])]
|
||||
class Subcategory extends Model
|
||||
{
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function customFields(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CustomField::class, 'custom_field_subcategory')
|
||||
->withPivot('position')
|
||||
->orderBy('custom_field_subcategory.position');
|
||||
}
|
||||
|
||||
public function teams(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Team::class, 'team_subcategory');
|
||||
}
|
||||
|
||||
public function tickets(): HasMany
|
||||
{
|
||||
return $this->hasMany(Ticket::class);
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->category->name.' / '.$this->name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user