akaunting/app/Models/Common/Dashboard.php

58 lines
1.2 KiB
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
namespace App\Models\Common;
use App\Abstracts\Model;
use Bkwld\Cloner\Cloneable;
2020-10-16 23:35:26 +03:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2019-11-16 10:21:14 +03:00
class Dashboard extends Model
{
2020-10-16 23:35:26 +03:00
use Cloneable, HasFactory;
2019-11-16 10:21:14 +03:00
protected $table = 'dashboards';
/**
* Attributes that should be mass-assignable.
*
* @var array
*/
2020-01-07 17:15:00 +03:00
protected $fillable = ['company_id', 'name', 'enabled'];
2019-11-16 10:21:14 +03:00
2020-11-13 15:15:27 +03:00
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'enabled' => 'boolean',
];
2019-11-16 10:21:14 +03:00
/**
* Sortable columns.
*
* @var array
*/
public $sortable = ['name', 'enabled'];
2020-01-07 17:15:00 +03:00
public function users()
2019-11-16 10:21:14 +03:00
{
2020-01-07 17:15:00 +03:00
return $this->morphedByMany('App\Models\Auth\User', 'user', 'user_dashboards', 'dashboard_id', 'user_id');
2019-11-16 10:21:14 +03:00
}
2019-12-31 11:27:49 +03:00
public function widgets()
2019-11-16 10:21:14 +03:00
{
2019-12-31 11:27:49 +03:00
return $this->hasMany('App\Models\Common\Widget')->orderBy('sort', 'asc');
2019-11-16 10:21:14 +03:00
}
2020-10-16 23:35:26 +03:00
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Database\Factories\Dashboard::new();
}
2019-11-16 10:21:14 +03:00
}