Make dashboard configurable.

This commit is contained in:
2025-02-06 11:08:30 +01:00
parent a545e253d3
commit 4c43bf2193
19 changed files with 535 additions and 159 deletions

54
app/Models/Dashboard.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Dashboard extends Model
{
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'width',
'height',
'sort',
'active',
'settings'
];
protected $appends = [
'title',
];
public function getTitleAttribute()
{
return __('dashboard.title_' . $this->name);
}
public static function toObject()
{
$all = self::orderBy('sort')->get();
$tiles = new \stdClass();
foreach ($all as $tile) {
$key = $tile->name;
$tiles->$key = $tile;
}
return $tiles;
}
public static function activeToObject()
{
$all = self::where('active', true)->orderBy('sort')->get();
$tiles = new \stdClass();
foreach ($all as $tile) {
$key = $tile->name;
$tiles->$key = $tile;
}
return collect($tiles);
}
}