added api for dashboards
This commit is contained in:
36
app/Transformers/Common/Widget.php
Normal file
36
app/Transformers/Common/Widget.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Common;
|
||||
|
||||
use App\Models\Common\Widget as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Widget extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
session(['dashboard_id' => $model->dashboard_id]);
|
||||
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'dashboard_id' => $model->dashboard_id,
|
||||
'class' => $model->class,
|
||||
'name' => $model->name,
|
||||
'sort' => $model->sort,
|
||||
'settings' => $model->settings,
|
||||
'data' => show_widget($model->class),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user