2017-01-13 04:50:20 -08:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Statuslabel;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2017-02-08 18:24:55 -08:00
|
|
|
use Gate;
|
2017-01-13 04:50:20 -08:00
|
|
|
|
|
|
|
class StatuslabelsTransformer
|
|
|
|
{
|
|
|
|
|
|
|
|
public function transformStatuslabels (Collection $statuslabels)
|
|
|
|
{
|
|
|
|
$array = array();
|
|
|
|
foreach ($statuslabels as $statuslabel) {
|
|
|
|
$array[] = self::transformStatuslabel($statuslabel);
|
|
|
|
}
|
|
|
|
return (new DatatablesTransformer)->transformDatatables($array);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function transformStatuslabel (Statuslabel $statuslabel)
|
|
|
|
{
|
|
|
|
$array = [
|
|
|
|
'id' => e($statuslabel->id),
|
|
|
|
'name' => e($statuslabel->name),
|
|
|
|
'type' => $statuslabel->getStatuslabelType(),
|
2017-02-01 17:48:28 -08:00
|
|
|
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
2017-01-13 04:50:20 -08:00
|
|
|
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false,
|
2017-02-01 17:48:28 -08:00
|
|
|
'notes' => e($statuslabel->notes),
|
2017-01-13 04:50:20 -08:00
|
|
|
'created_at' => $statuslabel->created_at,
|
|
|
|
'updated_at' => $statuslabel->updated_at,
|
|
|
|
];
|
|
|
|
|
2017-02-08 18:24:55 -08:00
|
|
|
$permissions_array['available_actions'] = [
|
|
|
|
'edit' => Gate::allows('admin') ? true : false,
|
|
|
|
'delete' => Gate::allows('admin') ? true : false,
|
|
|
|
];
|
|
|
|
$array += $permissions_array;
|
|
|
|
|
2017-01-13 04:50:20 -08:00
|
|
|
return $array;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|