ADD: nrpv a vehicle y paginación a usuarios
This commit is contained in:
parent
906299ac10
commit
7ad6f87b17
@ -29,26 +29,24 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$users = User::orderBy('name');
|
$users = User::with([
|
||||||
|
'module:id,name',
|
||||||
|
'roles:name'
|
||||||
|
])->orderBy('name');
|
||||||
|
|
||||||
QuerySupport::queryByKeys($users, ['name', 'email']);
|
QuerySupport::queryByKeys($users, ['name', 'email']);
|
||||||
|
|
||||||
return ApiResponse::OK->response([
|
return ApiResponse::OK->response([
|
||||||
/* 'models' => $users->paginate(config('app.pagination')), */
|
/* 'models' => $users->paginate(config('app.pagination')), */
|
||||||
'users' => $users->paginate(config('app.pagination'))->map(function($user) {
|
'users' => $users->select([
|
||||||
return [
|
'id',
|
||||||
'id' => $user->id,
|
'name',
|
||||||
'name' => $user->full_name,
|
'paternal',
|
||||||
'username' => $user->name, // username corto
|
'maternal',
|
||||||
'email' => $user->email,
|
'email',
|
||||||
'module' => $user->module ? [
|
'module_id',
|
||||||
'id' => $user->module->id,
|
'deleted_at'
|
||||||
'name' => $user->module->name,
|
])->paginate(config('app.pagination'))
|
||||||
] : null,
|
|
||||||
'roles' => $user->roles->pluck('name')->toArray(),
|
|
||||||
'status' => $user->deleted_at ? 'De Baja' : 'Activo',
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('vehicle', function (Blueprint $table) {
|
||||||
|
$table->string('nrpv')->nullable()->after('cve_vehi');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('vehicle', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('nrpv');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user