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()
|
||||
{
|
||||
$users = User::orderBy('name');
|
||||
$users = User::with([
|
||||
'module:id,name',
|
||||
'roles:name'
|
||||
])->orderBy('name');
|
||||
|
||||
QuerySupport::queryByKeys($users, ['name', 'email']);
|
||||
|
||||
return ApiResponse::OK->response([
|
||||
/* 'models' => $users->paginate(config('app.pagination')), */
|
||||
'users' => $users->paginate(config('app.pagination'))->map(function($user) {
|
||||
return [
|
||||
'id' => $user->id,
|
||||
'name' => $user->full_name,
|
||||
'username' => $user->name, // username corto
|
||||
'email' => $user->email,
|
||||
'module' => $user->module ? [
|
||||
'id' => $user->module->id,
|
||||
'name' => $user->module->name,
|
||||
] : null,
|
||||
'roles' => $user->roles->pluck('name')->toArray(),
|
||||
'status' => $user->deleted_at ? 'De Baja' : 'Activo',
|
||||
];
|
||||
}),
|
||||
'users' => $users->select([
|
||||
'id',
|
||||
'name',
|
||||
'paternal',
|
||||
'maternal',
|
||||
'email',
|
||||
'module_id',
|
||||
'deleted_at'
|
||||
])->paginate(config('app.pagination'))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -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