diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 24689d6ba1..0ac91630c3 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Helpers\Helper; use App\Models\Location; +use App\Http\Transformers\DatatablesTransformer; class LocationsController extends Controller { @@ -20,7 +21,7 @@ class LocationsController extends Controller { $this->authorize('view', Location::class); $locations = Location::all(); - return $locations; + return (new DatatablesTransformer)->transformDatatables($locations); } diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 7448126b8d..54be995eb9 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Transformers\UsersTransformer; +use App\Http\Transformers\DatatablesTransformer; use App\Models\User; class UsersController extends Controller diff --git a/app/Http/Transformers/DatatablesTransformer.php b/app/Http/Transformers/DatatablesTransformer.php new file mode 100644 index 0000000000..99c0551fda --- /dev/null +++ b/app/Http/Transformers/DatatablesTransformer.php @@ -0,0 +1,16 @@ + e($location->id), - 'name' => e($location->name) + 'name' => e($location->name), + 'address' => e($location->address), + 'city' => e($location->city), + 'state' => e($location->state), + 'country' => e($location->country), ]; return $locations_array; } diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 52edf81c31..592a67159c 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -13,15 +13,19 @@ class UsersTransformer foreach ($users as $user) { $users_array[] = self::transformUser($user); } - return $users_array; + return (new DatatablesTransformer)->transformDatatables($users_array); } public function transformUser(User $user) { $user_array[] = [ 'id' => e($user->id), - 'first_name' => e($user->first_name), - 'last_name' => e($user->last_name), + 'name' => e($user->first_name).' '.($user->last_name), + 'firstname' => e($user->first_name), + 'lastname' => e($user->last_name), + 'username' => e($user->username), + 'jobtitle' => e($user->jobtitle), + 'email' => e($user->email), 'location' => (new LocationsTransformer)->transformLocation($user->userloc), 'permissions' => $user->decodePermissions(), 'created_at' => $user->created_at, @@ -31,6 +35,10 @@ class UsersTransformer return $user_array; } + public function transformUsersDatatable($users) { + return (new DatatablesTransformer)->transformDatatables($users); + } + } diff --git a/resources/views/locations/index.blade.php b/resources/views/locations/index.blade.php index 23d83f1670..d38624ca03 100755 --- a/resources/views/locations/index.blade.php +++ b/resources/views/locations/index.blade.php @@ -21,7 +21,7 @@ name="locations" class="table table-striped snipe-table" id="table" - data-url="{{ route('api.locations.list') }}" + data-url="{{ route('api.locations.index') }}" data-cookie="true" data-click-to-select="true" data-cookie-id-table="locationsTable-{{ config('version.hash_version') }}"> diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index 2cdb0399af..5557f7206a 100755 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -61,7 +61,7 @@ class="table table-striped snipe-table" id="table" data-toggle="table" - data-url="{{ route('api.users.list', array(''=>e(Input::get('status')))) }}" + data-url="{{ route('api.users.index', array(''=>e(Input::get('status')))) }}" data-cookie="true" data-click-to-select="true" data-cookie-id-table="userTableDisplay-{{ config('version.hash_version') }}"> diff --git a/routes/api.php b/routes/api.php index 994b992cb4..6ff965d3d7 100644 --- a/routes/api.php +++ b/routes/api.php @@ -47,7 +47,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); - Route::resource('location', 'LocationsController', + Route::resource('locations', 'LocationsController', ['names' => [ 'index' => 'api.locations.index', diff --git a/routes/web.php b/routes/web.php index 7c0a77e3df..93240d297e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,5 @@ ['component' => 'component_id'] +]); + + /* |-------------------------------------------------------------------------- | Log Routes