fixed like action, better dark mode, bottom navigation working, added taskcollection
This commit is contained in:
67
app/Models/TaskCollection.php
Normal file
67
app/Models/TaskCollection.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class TaskCollection extends Model
|
||||
{
|
||||
protected $table = 'task_collections';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'name' => 'array',
|
||||
'description' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tasks in this collection
|
||||
*/
|
||||
public function tasks(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Task::class,
|
||||
'task_collection_task',
|
||||
'task_collection_id',
|
||||
'task_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Events that use this collection
|
||||
*/
|
||||
public function events(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Event::class,
|
||||
'event_task_collection',
|
||||
'task_collection_id',
|
||||
'event_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized name for the current locale
|
||||
*/
|
||||
public function getLocalizedNameAttribute(): string
|
||||
{
|
||||
$locale = app()->getLocale();
|
||||
return $this->name[$locale] ?? $this->name['de'] ?? 'Unnamed Collection';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized description for the current locale
|
||||
*/
|
||||
public function getLocalizedDescriptionAttribute(): ?string
|
||||
{
|
||||
if (!$this->description) return null;
|
||||
|
||||
$locale = app()->getLocale();
|
||||
return $this->description[$locale] ?? $this->description['de'] ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user