55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?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);
|
|
}
|
|
}
|