Added updated/created to locations API

This commit is contained in:
snipe 2017-03-10 22:09:21 -08:00
parent c132036f5c
commit caf2f648b1
2 changed files with 7 additions and 1 deletions

View file

@ -20,7 +20,8 @@ class LocationsController extends Controller
public function index(Request $request)
{
$this->authorize('view', Location::class);
$allowed_columns = ['id','name','address','address2','city','state','country','zip'];
$allowed_columns = ['id','name','address','address2','city','state','country','zip','created_at',
'updated_at'];
$locations = Location::select([
'locations.id',
@ -32,6 +33,8 @@ class LocationsController extends Controller
'locations.zip',
'locations.country',
'locations.parent_id',
'locations.created_at',
'locations.updated_at',
'locations.currency'
])->withCount('assets')->withCount('users');

View file

@ -4,6 +4,7 @@ namespace App\Http\Transformers;
use App\Models\Location;
use Illuminate\Database\Eloquent\Collection;
use Gate;
use App\Helpers\Helper;
class LocationsTransformer
{
@ -36,6 +37,8 @@ class LocationsTransformer
'assets_default' => $location->assignedassets()->count(),
'country' => e($location->country),
'assets' => $assets_arr,
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [