shared dashboards

This commit is contained in:
denisdulici
2020-01-07 17:15:00 +03:00
parent dcab115207
commit 2436898f04
33 changed files with 806 additions and 457 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Jobs\Common;
use App\Abstracts\Job;
use App\Models\Common\Dashboard;
class CreateDashboard extends Job
{
protected $request;
/**
* Create a new job instance.
*
* @param $request
*/
public function __construct($request)
{
$this->request = $this->getRequestInstance($request);
}
/**
* Execute the job.
*
* @return Item
*/
public function handle()
{
$this->request['enabled'] = $this->request['enabled'] ?? 1;
$this->dashboard = Dashboard::create($this->request->all());
$this->attachToUser();
return $this->dashboard;
}
protected function attachToUser()
{
if ($this->request->has('users')) {
$user = $this->request->get('users');
} else {
$user = user();
}
if (empty($user)) {
return;
}
$this->dashboard->users()->attach($user);
}
}