create a dashboard if none available
This commit is contained in:
@ -3,14 +3,14 @@
|
||||
namespace Database\Seeds;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Widget;
|
||||
use App\Models\Common\Dashboard;
|
||||
use App\Utilities\Widgets;
|
||||
use App\Jobs\Common\CreateDashboard;
|
||||
use App\Traits\Jobs;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class Dashboards extends Seeder
|
||||
{
|
||||
use Jobs;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
@ -30,29 +30,11 @@ class Dashboards extends Seeder
|
||||
$user_id = $this->command->argument('user');
|
||||
$company_id = $this->command->argument('company');
|
||||
|
||||
$dashboard = Dashboard::create([
|
||||
$this->dispatch(new CreateDashboard([
|
||||
'company_id' => $company_id,
|
||||
'name' => trans_choice('general.dashboards', 1),
|
||||
'enabled' => 1,
|
||||
]);
|
||||
|
||||
$widgets = Widgets::getClasses(false);
|
||||
|
||||
$sort = 1;
|
||||
|
||||
foreach ($widgets as $class => $name) {
|
||||
Widget::create([
|
||||
'company_id' => $company_id,
|
||||
'dashboard_id' => $dashboard->id,
|
||||
'class' => $class,
|
||||
'name' => $name,
|
||||
'sort' => $sort,
|
||||
'settings' => (new $class())->getDefaultSettings(),
|
||||
]);
|
||||
|
||||
$sort++;
|
||||
}
|
||||
|
||||
User::find($user_id)->dashboards()->attach($dashboard->id);
|
||||
'with_widgets' => true,
|
||||
'users' => $user_id,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user