widget permissions
This commit is contained in:
@ -7,6 +7,7 @@ use App\Http\Requests\Common\Dashboard as Request;
|
||||
use App\Models\Common\Dashboard as Model;
|
||||
use App\Models\Common\Widget;
|
||||
use App\Traits\DateTime;
|
||||
use App\Utilities\Widgets as WidgetUtility;
|
||||
|
||||
class Dashboard extends Controller
|
||||
{
|
||||
@ -31,14 +32,16 @@ class Dashboard extends Controller
|
||||
$dashboards = Model::where('user_id', user()->id)->enabled()->get();
|
||||
|
||||
if (!$dashboard_id) {
|
||||
$dashboard_id = $dashboards->first()->id;
|
||||
$dashboard_id = $dashboards->pluck('id')->first();
|
||||
}
|
||||
|
||||
// Dashboard
|
||||
$dashboard = Model::find($dashboard_id);
|
||||
|
||||
// Widgets
|
||||
$widgets = Widget::where('dashboard_id', $dashboard->id)->orderBy('sort', 'asc')->get();
|
||||
$widgets = Widget::where('dashboard_id', $dashboard->id)->orderBy('sort', 'asc')->get()->filter(function ($widget) {
|
||||
return WidgetUtility::canRead($widget->class);
|
||||
})->all();
|
||||
|
||||
$financial_start = $this->getFinancialStart()->format('Y-m-d');
|
||||
|
||||
|
@ -24,12 +24,12 @@ class Reports extends Controller
|
||||
$reports = Report::collect();
|
||||
|
||||
foreach ($reports as $report) {
|
||||
$class = Utility::getClassInstance($report);
|
||||
|
||||
if (!$class->canRead()) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = Utility::getClassInstance($report);
|
||||
|
||||
$classes[$report->id] = $class;
|
||||
|
||||
$categories[$class->getCategory()][] = $report;
|
||||
@ -46,13 +46,11 @@ class Reports extends Controller
|
||||
*/
|
||||
public function show(Report $report)
|
||||
{
|
||||
$class = Utility::getClassInstance($report);
|
||||
|
||||
if (!$class->canRead()) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return $class->show();
|
||||
return Utility::getClassInstance($report)->show();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,13 +184,11 @@ class Reports extends Controller
|
||||
*/
|
||||
public function print(Report $report)
|
||||
{
|
||||
$class = Utility::getClassInstance($report);
|
||||
|
||||
if (!$class->canRead()) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return $class->print();
|
||||
return Utility::getClassInstance($report)->print();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,13 +199,11 @@ class Reports extends Controller
|
||||
*/
|
||||
public function export(Report $report)
|
||||
{
|
||||
$class = Utility::getClassInstance($report);
|
||||
|
||||
if (!$class->canRead()) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return $class->export();
|
||||
return Utility::getClassInstance($report)->export();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user