new widget structure

This commit is contained in:
denisdulici
2019-12-31 02:20:10 +03:00
parent 8c6ca5e5fb
commit 71c5caf264
44 changed files with 333 additions and 502 deletions

View File

@ -5,7 +5,7 @@ namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Common\Widget;
use App\Models\Common\Dashboard;
use App\Models\Common\DashboardWidget;
use App\Utilities\Widgets as WidgetUtility;
use Illuminate\Database\Seeder;
class Dashboards extends Seeder
@ -29,35 +29,28 @@ class Dashboards extends Seeder
$user_id = $this->command->argument('user');
$company_id = $this->command->argument('company');
$rows = [
[
$dashboard = Dashboard::create([
'company_id' => $company_id,
'user_id' => $user_id,
'name' => trans('general.dashboard'),
'enabled' => 1,
]);
$widgets = WidgetUtility::getClasses();
$sort = 1;
foreach ($widgets as $class => $name) {
Widget::create([
'company_id' => $company_id,
'user_id' => $user_id,
'name' => trans('general.dashboard'),
'enabled' => 1,
]
];
'dashboard_id' => $dashboard->id,
'class' => $class,
'name' => $name,
'settings' => (new $class())->getDefaultSettings(),
'sort' => $sort,
]);
foreach ($rows as $row) {
$dashboard = Dashboard::create($row);
$widgets = Widget::where('company_id', $company_id)->orderBy('created_at','desc')->get();
$sort = 1;
foreach ($widgets as $widget) {
DashboardWidget::create([
'company_id' => $company_id,
'user_id' => $user_id,
'dashboard_id' => $dashboard->id,
'widget_id' => $widget->id,
'name' => $widget->name,
'settings' => $widget->settings,
'sort' => $sort
]);
$sort++;
}
$sort++;
}
}
}