Prepare modules
This commit is contained in:
@ -5,7 +5,7 @@ namespace Koneko\VuexyAdmin\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\{Auth,DB,Validator};
|
||||
use Illuminate\Support\Facades\{Auth,Validator};
|
||||
use Koneko\VuexyAdmin\Models\User;
|
||||
use Koneko\VuexyAdmin\Services\AvatarImageService;
|
||||
use Koneko\VuexyAdmin\Queries\GenericQueryBuilder;
|
||||
@ -24,97 +24,19 @@ class UserController extends Controller
|
||||
'table' => 'users',
|
||||
'columns' => [
|
||||
'users.id',
|
||||
'users.code',
|
||||
DB::raw("CONCAT_WS(' ', users.name, users.last_name) AS full_name"),
|
||||
'users.name AS full_name',
|
||||
'users.email',
|
||||
'users.birth_date',
|
||||
'users.hire_date',
|
||||
'users.curp',
|
||||
'users.nss',
|
||||
'users.job_title',
|
||||
'users.email_verified_at',
|
||||
'users.profile_photo_path',
|
||||
DB::raw("(SELECT GROUP_CONCAT(roles.name SEPARATOR ';') as roles FROM model_has_roles INNER JOIN roles ON (model_has_roles.role_id = roles.id) WHERE model_has_roles.model_id = 1) as roles"),
|
||||
'users.is_partner',
|
||||
'users.is_employee',
|
||||
'users.is_prospect',
|
||||
'users.is_customer',
|
||||
'users.is_provider',
|
||||
'users.is_user',
|
||||
'users.status',
|
||||
DB::raw("CONCAT_WS(' ', created.name, created.last_name) AS creator"),
|
||||
'created.email AS creator_email',
|
||||
'users.created_by',
|
||||
'users.created_at',
|
||||
'users.updated_at',
|
||||
],
|
||||
'joins' => [
|
||||
[
|
||||
'table' => 'users as parent',
|
||||
'first' => 'users.parent_id',
|
||||
'second' => 'parent.id',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
[
|
||||
'table' => 'users as agent',
|
||||
'first' => 'users.agent_id',
|
||||
'second' => 'agent.id',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
[
|
||||
'table' => 'users as created',
|
||||
'first' => 'users.created_by',
|
||||
'second' => 'created.id',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
[
|
||||
'table' => 'sat_codigo_postal',
|
||||
'first' => 'users.domicilio_fiscal',
|
||||
'second' => 'sat_codigo_postal.c_codigo_postal',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
[
|
||||
'table' => 'sat_estado',
|
||||
'first' => 'sat_codigo_postal.c_estado',
|
||||
'second' => 'sat_estado.c_estado',
|
||||
'type' => 'leftJoin',
|
||||
'and' => [
|
||||
'sat_estado.c_pais = "MEX"',
|
||||
],
|
||||
],
|
||||
[
|
||||
'table' => 'sat_localidad',
|
||||
'first' => 'sat_codigo_postal.c_localidad',
|
||||
'second' => 'sat_localidad.c_localidad',
|
||||
'type' => 'leftJoin',
|
||||
'and' => [
|
||||
'sat_codigo_postal.c_estado = sat_localidad.c_estado',
|
||||
],
|
||||
],
|
||||
[
|
||||
'table' => 'sat_municipio',
|
||||
'first' => 'sat_codigo_postal.c_municipio',
|
||||
'second' => 'sat_municipio.c_municipio',
|
||||
'type' => 'leftJoin',
|
||||
'and' => [
|
||||
'sat_codigo_postal.c_estado = sat_municipio.c_estado',
|
||||
],
|
||||
],
|
||||
[
|
||||
'table' => 'sat_regimen_fiscal',
|
||||
'first' => 'users.c_regimen_fiscal',
|
||||
'second' => 'sat_regimen_fiscal.c_regimen_fiscal',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
[
|
||||
'table' => 'sat_uso_cfdi',
|
||||
'first' => 'users.c_uso_cfdi',
|
||||
'second' => 'sat_uso_cfdi.c_uso_cfdi',
|
||||
'type' => 'leftJoin',
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'search' => ['users.name', 'users.email', 'users.code', 'parent.name', 'created.name'],
|
||||
'search' => ['users.code', 'users.full_name', 'users.email', 'parent_name'],
|
||||
],
|
||||
'sort_column' => 'users.name',
|
||||
'sort_column' => 'users.full_name',
|
||||
'default_sort_order' => 'asc',
|
||||
];
|
||||
|
||||
@ -160,9 +82,7 @@ class UserController extends Controller
|
||||
//$user->stores()->attach($request->stores);
|
||||
|
||||
if ($request->file('photo')){
|
||||
$avatarImageService = new AvatarImageService();
|
||||
|
||||
$avatarImageService->updateProfilePhoto($user, $request->file('photo'));
|
||||
app(AvatarImageService::class)->updateProfilePhoto($user, $request->file('photo'));
|
||||
}
|
||||
|
||||
return response()->json(['success' => 'Se agrego correctamente el usuario']);
|
||||
@ -217,10 +137,9 @@ class UserController extends Controller
|
||||
//$user->stores()->sync($request->stores);
|
||||
|
||||
// Actualizamos foto de perfil
|
||||
if ($request->file('photo'))
|
||||
$avatarImageService = new AvatarImageService();
|
||||
|
||||
$avatarImageService->updateProfilePhoto($user, $request->file('photo'));
|
||||
if ($request->file('photo')){
|
||||
app(AvatarImageService::class)->updateProfilePhoto($user, $request->file('photo'));
|
||||
}
|
||||
|
||||
return response()->json(['success' => 'Se guardo correctamente los cambios.']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user