Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1468 eleazar 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Controller;
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
9
use Laminas\Mvc\Controller\AbstractActionController;
10
use Laminas\Log\LoggerInterface;
11
use Laminas\View\Model\ViewModel;
12
use Laminas\View\Model\JsonModel;
1471 eleazar 13
use LeadersLinked\Form\RecruitmentSelectionCandidateFormForm;
1468 eleazar 14
use LeadersLinked\Library\Functions;
1479 eleazar 15
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
1468 eleazar 16
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
17
use LeadersLinked\Model\RecruitmentSelectionCandidate;
18
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
19
use LeadersLinked\Model\RecruitmentSelectionVacancy;
20
use LeadersLinked\Mapper\BehaviorMapper;
1473 eleazar 21
use LeadersLinked\Mapper\UserMapper;
1468 eleazar 22
use LeadersLinked\Mapper\CompanyMapper;
23
use LeadersLinked\Model\Company;
1601 eleazar 24
use Laminas\Hydrator\ArraySerializableHydrator;
25
use Laminas\Db\ResultSet\HydratingResultSet;
26
use LeadersLinked\Mapper\QueryMapper;
27
use Laminas\Paginator\Adapter\DbSelect;
28
use Laminas\Paginator\Paginator;
1468 eleazar 29
 
1470 eleazar 30
class RecruitmentSelectionCandidateController extends AbstractActionController{
31
 
32
    /**
1468 eleazar 33
     *
34
     * @var AdapterInterface
35
     */
36
    private $adapter;
37
 
38
    /**
39
     *
40
     * @var AbstractAdapter
41
     */
42
    private $cache;
43
 
44
    /**
45
     *
46
     * @var  LoggerInterface
47
     */
48
    private $logger;
49
 
50
    /**
51
     *
52
     * @var array
53
     */
54
    private $config;
55
 
56
    /**
57
     *
58
     * @param AdapterInterface $adapter
59
     * @param AbstractAdapter $cache
60
     * @param LoggerInterface $logger
61
     * @param array $config
62
     */
63
    public function __construct($adapter, $cache, $logger, $config) {
64
        $this->adapter = $adapter;
65
        $this->cache = $cache;
66
        $this->logger = $logger;
67
        $this->config = $config;
68
    }
69
 
70
    public function indexAction() {
71
        $currentUserPlugin = $this->plugin('currentUserPlugin');
72
        $currentUser = $currentUserPlugin->getUser();
73
        $currentCompany = $currentUserPlugin->getCompany();
74
 
75
        $request = $this->getRequest();
76
 
77
        if ($request->isGet()) {
78
 
79
            $headers = $request->getHeaders();
80
 
81
            $isJson = false;
82
            if ($headers->has('Accept')) {
83
                $accept = $headers->get('Accept');
84
 
85
                $prioritized = $accept->getPrioritized();
86
 
87
                foreach ($prioritized as $key => $value) {
88
                    $raw = trim($value->getRaw());
89
 
90
                    if (!$isJson) {
91
                        $isJson = strpos($raw, 'json');
92
                    }
93
                }
94
            }
95
 
96
            if ($isJson) {
1477 efrain 97
                //$form_uuid = filter_var($this->params()->fromQuery('form_uuid'), FILTER_SANITIZE_STRING);
1468 eleazar 98
 
1502 eleazar 99
                $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
1501 eleazar 100
 
1468 eleazar 101
                $data = [
102
                    'items' => [],
103
                    'total' => 0,
104
                ];
105
 
106
 
1477 efrain 107
                if (!$vacancy_uuid) {
1468 eleazar 108
                    return new JsonModel([
109
                        'success' => true,
110
                        'data' => $data
111
                    ]);
112
                }
113
 
114
 
1477 efrain 115
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
116
                $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
117
                if (! $vacancy) {
1468 eleazar 118
                    return new JsonModel([
119
                        'success' => true,
120
                        'data' => 'ERROR_FORM_NOT_FOUND'
121
                    ]);
122
                }
123
 
1477 efrain 124
                if ( $vacancy->company_id != $currentCompany->id) {
1468 eleazar 125
                    return new JsonModel([
126
                        'success' => true,
127
                        'data' => 'ERROR_UNAUTHORIZED'
128
                    ]);
129
                }
130
 
131
 
10095 stevensc 132
                $search = $this->params()->fromQuery('search');
133
                $search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
1468 eleazar 134
 
135
                $page = intval($this->params()->fromQuery('start', 1), 10);
136
                $records_x_page = intval($this->params()->fromQuery('length', 10), 10);
137
                $order = $this->params()->fromQuery('order', []);
138
                $order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
139
                $order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
140
 
8890 eleazar 141
                $fields = ['uuid', 'first_name', 'last_name', 'email', 'status'];
1468 eleazar 142
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
143
 
144
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
145
                    $order_direction = 'ASC';
146
                }
147
 
148
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
8786 eleazar 149
                $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/add');
150
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/edit');
151
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/delete');
1636 eleazar 152
                $allowEmail = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/user-by-email');
1468 eleazar 153
 
1600 eleazar 154
                $queryMapper = QueryMapper::getInstance($this->adapter);
155
                $sql = $queryMapper->getSql();
156
                $select = $sql->select();
8889 eleazar 157
                $select->columns(['id', 'uuid', 'first_name', 'last_name', 'email', 'file', 'status']);
1600 eleazar 158
                $select->from(['tb1' => RecruitmentSelectionCandidateMapper::_TABLE]);
2681 eleazar 159
                $select->where->equalTo('tb1.vacancy_id', $vacancy->id);
1468 eleazar 160
 
1600 eleazar 161
                if($search) {
162
                    $select->where->nest()
163
                    ->like('first_name', '%' . $search . '%')
164
                    ->or->like('last_name', '%' . $search . '%')
165
                    ->or->like('email', '%' . $search . '%')
166
                    ->unnest();
167
                }
168
 
169
                $select->order($order_field . ' ' . $order_direction);
170
 
1468 eleazar 171
                $hydrator = new ArraySerializableHydrator();
172
                $resultset = new HydratingResultSet($hydrator);
173
 
174
                $adapter = new DbSelect($select, $sql, $resultset);
175
                $paginator = new Paginator($adapter);
176
                $paginator->setItemCountPerPage($records_x_page);
177
                $paginator->setCurrentPageNumber($page);
178
 
179
 
180
                $items = [];
181
                $records = $paginator->getCurrentItems();
4503 eleazar 182
 
6237 eleazar 183
 
1468 eleazar 184
                foreach ($records as $record) {
185
                    $params = [
1608 eleazar 186
                        'vacancy_uuid' => $vacancy->uuid,
187
                        'id' => $record['uuid'],
1468 eleazar 188
                    ];
189
 
8786 eleazar 190
                    $link_delete = $this->url()->fromRoute('recruitment-and-selection/candidates/delete', $params);
1624 eleazar 191
 
8786 eleazar 192
                    $link_edit = $this->url()->fromRoute('recruitment-and-selection/candidates/edit', $params);
1624 eleazar 193
 
1468 eleazar 194
                    $item = [
195
                        'uuid' => $record['uuid'],
196
                        'first_name' => $record['first_name'],
197
                        'last_name' => $record['last_name'],
198
                        'email' => $record['email'],
8889 eleazar 199
                        'status' => $record['status'],
1611 eleazar 200
                        // 'file' => $this->url()->fromRoute('storage', ['type' => 'recruitment_selection', 'code' => $record['uuid'], 'filename' => $record['file']]),
1468 eleazar 201
                        'actions' => [
1614 eleazar 202
                            'link_edit' => $allowEdit ? $link_edit : '',
1468 eleazar 203
                            'link_delete' => $allowDelete ? $link_delete : '',
204
                        ]
205
                    ];
206
 
207
                    array_push($items, $item);
208
                }
209
 
210
                $data['items'] = $items;
211
                $data['total'] = $paginator->getTotalItemCount();
212
 
213
 
214
                return new JsonModel([
215
                    'success' => true,
216
                    'data' => $data
217
                ]);
218
            } else {
219
                $form = new RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
10753 stevensc 220
 
10131 stevensc 221
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
10753 stevensc 222
                $vacancies = $vacancyMapper->fetchAllByCompanyId($currentCompany->id);
10132 stevensc 223
 
10131 stevensc 224
 
1468 eleazar 225
                $this->layout()->setTemplate('layout/layout-backend');
226
                $viewModel = new ViewModel();
1475 eleazar 227
                $viewModel->setTemplate('leaders-linked/recruitment-and-selection-candidates/index.phtml');
10131 stevensc 228
                $viewModel->setVariables([
229
                    'form' => $form,
230
                    'vacancies' => $vacancies,
231
                ]);
1468 eleazar 232
 
233
                return $viewModel;
234
            }
235
        } else {
236
            return new JsonModel([
237
                'success' => false,
238
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
239
            ]);
240
            ;
241
        }
242
    }
243
 
1485 eleazar 244
    public function addAction()
245
    {
246
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
247
        $currentCompany     = $currentUserPlugin->getCompany();
248
        $currentUser        = $currentUserPlugin->getUser();
249
 
250
        $request    = $this->getRequest();
251
 
1515 eleazar 252
        $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
253
 
1485 eleazar 254
        if($request->isPost()) {
1513 eleazar 255
            $form = new  RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
1516 eleazar 256
            $dataPost = array_merge(
257
                $request->getPost()->toArray(),
258
                $request->getFiles()->toArray(),
259
                ['form_uuid' => $vacancy_uuid],
260
            );
1485 eleazar 261
 
262
            $form->setData($dataPost);
263
 
264
            if($form->isValid()) {
265
                $dataPost = (array) $form->getData();
266
 
1592 eleazar 267
                $files = $this->getRequest()->getFiles()->toArray();
268
 
1485 eleazar 269
                $hydrator = new ObjectPropertyHydrator();
270
                $candidate = new RecruitmentSelectionCandidate();
271
                $hydrator->hydrate($dataPost, $candidate);
272
 
273
                $candidate->company_id = $currentCompany->id;
1586 eleazar 274
                $candidate->file = null;
1520 eleazar 275
 
276
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
277
                $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
278
 
2680 eleazar 279
                $candidate->vacancy_id = $vacancy->id;
1494 eleazar 280
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1518 eleazar 281
 
1534 eleazar 282
                if($candidateMapper->insert($candidate)) {
1593 eleazar 283
                     $candidate = $candidateMapper->fetchOne($candidate->id);
1485 eleazar 284
 
285
                    //leaderslinked.fullpath.recruitment_selection/uuid vacante/uuid candidato
286
 
8581 eleazar 287
                     $target_path = $this->config['leaderslinked.fullpath.recruitment_selection'].$vacancy->uuid.DIRECTORY_SEPARATOR.$candidate->uuid;
1582 eleazar 288
                     if(!file_exists($target_path)) {
289
                         mkdir($target_path, 0755, true);
290
                     }
291
                    $files = $this->getRequest()->getFiles()->toArray();
292
                     if(isset($files['file']) && empty($files['file']['error'])) {
293
                         $tmp_filename  = $files['file']['tmp_name'];
1592 eleazar 294
                         $original_filename  = trim(strtolower($files['file']['name']));
1582 eleazar 295
                        try {
1592 eleazar 296
                            $parts = explode('.', $original_filename);
297
                            $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
298
 
299
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
300
                            if(move_uploaded_file($tmp_filename, $full_filename)) {
1582 eleazar 301
                                 $candidate->file = $filename;
302
                                 $candidateMapper->update($candidate);
303
                             }
304
                         } catch(\Throwable $e) {
305
                             error_log($e->getTraceAsString());
306
                         }
307
                     }
1518 eleazar 308
 
1588 eleazar 309
                    $this->logger->info('Se agrego el candidato ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1485 eleazar 310
 
311
                    $data = [
312
                        'success'   => true,
313
                        'data'   => 'LABEL_RECORD_ADDED'
314
                    ];
315
                } else {
316
                    $data = [
317
                        'success'   => false,
1494 eleazar 318
                        'data'      => $candidateMapper->getError()
1485 eleazar 319
                    ];
320
 
321
                }
322
 
323
                return new JsonModel($data);
324
 
325
            } else {
326
                $messages = [];
327
                $form_messages = (array) $form->getMessages();
328
                foreach($form_messages  as $fieldname => $field_messages)
329
                {
330
 
331
                    $messages[$fieldname] = array_values($field_messages);
332
                }
333
 
334
            }
335
 
336
        } else {
337
            $data = [
338
                'success' => false,
339
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
340
            ];
341
 
342
            return new JsonModel($data);
343
        }
344
 
345
        return new JsonModel($data);
346
    }
1614 eleazar 347
 
348
    public function editAction() {
349
        $request = $this->getRequest();
350
        $currentUserPlugin = $this->plugin('currentUserPlugin');
351
        $currentCompany = $currentUserPlugin->getCompany();
352
        $currentUser = $currentUserPlugin->getUser();
353
 
354
        $request = $this->getRequest();
1623 eleazar 355
        $id = $this->params()->fromRoute('id');
1614 eleazar 356
 
1625 eleazar 357
        if (!$id) {
1614 eleazar 358
            $data = [
359
                'success' => false,
360
                'data' => 'ERROR_INVALID_PARAMETER'
361
            ];
362
 
363
            return new JsonModel($data);
364
        }
365
 
366
        $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1625 eleazar 367
        $candidate = $recruitmentSelectionCandidateMapper->fetchOneByUuid($id);
368
 
369
        if (!$candidate) {
1614 eleazar 370
            $data = [
371
                'success' => false,
372
                'data' => 'ERROR_RECORD_NOT_FOUND'
373
            ];
374
 
375
            return new JsonModel($data);
376
        }
377
 
1625 eleazar 378
        if ($candidate->company_id != $currentCompany->id) {
1614 eleazar 379
            return new JsonModel([
380
                'success' => false,
381
                'data' => 'ERROR_UNAUTHORIZED'
382
            ]);
383
        }
8540 efrain 384
 
385
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
386
        $vacancy = $vacancyMapper->fetchOne($candidate->vacancy_id);
387
 
1614 eleazar 388
 
8540 efrain 389
 
1614 eleazar 390
        if ($request->isPost()) {
1626 eleazar 391
            $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
1614 eleazar 392
            $form = new RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
393
            $dataPost = $request->getPost()->toArray();
3879 eleazar 394
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionCandidate::STATUS_REJECTED;
1626 eleazar 395
            $dataPost['form_uuid'] = $vacancy_uuid;
1614 eleazar 396
 
397
            $form->setData($dataPost);
398
 
399
            if ($form->isValid()) {
400
                $dataPost = (array) $form->getData();
401
 
402
                $hydrator = new ObjectPropertyHydrator();
403
                $hydrator->hydrate($dataPost, $candidate);
404
 
1625 eleazar 405
                if($recruitmentSelectionCandidateMapper->update($candidate)) {
406
                    $candidate = $recruitmentSelectionCandidateMapper->fetchOne($candidate->id);
1623 eleazar 407
 
408
                   //leaderslinked.fullpath.recruitment_selection/uuid vacante/uuid candidato
409
 
8581 eleazar 410
                    $target_path = $this->config['leaderslinked.fullpath.recruitment_selection'].$vacancy_uuid.DIRECTORY_SEPARATOR.$candidate->uuid;
1623 eleazar 411
                    if(!file_exists($target_path)) {
412
                        mkdir($target_path, 0755, true);
413
                    }
1625 eleazar 414
 
415
                    $files = $this->getRequest()->getFiles()->toArray();
416
 
1623 eleazar 417
                    if(isset($files['file']) && empty($files['file']['error'])) {
418
                        $tmp_filename  = $files['file']['tmp_name'];
419
                        $original_filename  = trim(strtolower($files['file']['name']));
1625 eleazar 420
 
421
                        try {
422
                            $parts = explode('.', $original_filename);
423
                            $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
424
 
425
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
426
                            if(move_uploaded_file($tmp_filename, $full_filename)) {
1623 eleazar 427
                                $candidate->file = $filename;
1625 eleazar 428
                                $recruitmentSelectionCandidateMapper->update($candidate);
1623 eleazar 429
                            }
430
                        } catch(\Throwable $e) {
431
                            error_log($e->getTraceAsString());
432
                        }
433
                    }
434
 
435
                   $this->logger->info('Se agrego el candidato ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
436
 
437
                   $data = [
438
                       'success'   => true,
1628 eleazar 439
                       'data'   => 'LABEL_RECORD_UPDATED'
1623 eleazar 440
                   ];
441
               } else {
442
                   $data = [
443
                       'success'   => false,
1625 eleazar 444
                       'data'      => $recruitmentSelectionCandidateMapper->getError()
1623 eleazar 445
                   ];
446
 
447
               }
448
 
1614 eleazar 449
                return new JsonModel($data);
450
            } else {
451
                $messages = [];
452
                $form_messages = (array) $form->getMessages();
453
                foreach ($form_messages as $fieldname => $field_messages) {
454
                    $messages[$fieldname] = array_values($field_messages);
455
                }
456
 
457
                return new JsonModel([
458
                    'success' => false,
459
                    'data' => $messages
460
                ]);
461
            }
462
        } else if ($request->isGet()) {
8539 efrain 463
 
1614 eleazar 464
            $hydrator = new ObjectPropertyHydrator();
465
 
466
            $data = [
467
                'success' => true,
468
                'data' => [
469
                    'id' => $candidate->uuid,
1660 eleazar 470
                    'user_id' => $candidate->user_id,
1614 eleazar 471
                    'first_name' => $candidate->first_name,
472
                    'last_name' => $candidate->last_name,
473
                    'email' => $candidate->email,
8540 efrain 474
                    'file' => $this->url()->fromRoute('storage', ['type' => 'recruitment-selection', 'code'=> $vacancy->uuid, 'code2'=> $candidate->uuid, 'filename' => $candidate->file]),
1658 eleazar 475
                    'evaluation' => $candidate->evaluation,
8608 eleazar 476
                    'coment' => strip_tags($candidate->coment),
1614 eleazar 477
                    'status' => $candidate->status,
478
                ]
479
            ];
480
 
481
            return new JsonModel($data);
482
        } else {
483
            $data = [
484
                'success' => false,
1619 eleazar 485
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1614 eleazar 486
            ];
487
 
488
            return new JsonModel($data);
489
        }
490
 
491
        return new JsonModel($data);
492
    }
493
 
494
    public function deleteAction() {
495
        $request = $this->getRequest();
496
        $currentUserPlugin = $this->plugin('currentUserPlugin');
497
        $currentCompany = $currentUserPlugin->getCompany();
498
        $currentUser = $currentUserPlugin->getUser();
499
 
500
        $request = $this->getRequest();
501
        $uuid = $this->params()->fromRoute('id');
502
 
503
        if (!$uuid) {
504
            $data = [
505
                'success' => false,
506
                'data' => 'ERROR_INVALID_PARAMETER'
507
            ];
508
 
509
            return new JsonModel($data);
510
        }
511
 
512
        $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
513
        $candidateMapper = $recruitmentSelectionCandidateMapper->fetchOneByUuid($uuid);
514
        if (!$candidateMapper) {
515
            $data = [
516
                'success' => false,
517
                'data' => 'ERROR_RECORD_NOT_FOUND'
518
            ];
519
 
520
            return new JsonModel($data);
521
        }
522
 
523
        if ($candidateMapper->company_id != $currentCompany->id) {
524
            return new JsonModel([
525
                'success' => false,
526
                'data' => 'ERROR_UNAUTHORIZED'
527
            ]);
528
        }
529
 
530
        if ($request->isPost()) {
531
 
532
 
533
            $result = $recruitmentSelectionCandidateMapper->delete($candidateMapper->id);
534
            if ($result) {
1615 eleazar 535
                $this->logger->info('Se borro el candidato ' . $candidateMapper->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1614 eleazar 536
 
537
                $data = [
538
                    'success' => true,
539
                    'data' => 'LABEL_RECORD_DELETED'
540
                ];
541
            } else {
542
 
543
                $data = [
544
                    'success' => false,
545
                    'data' => $recruitmentSelectionCandidateMapper->getError()
546
                ];
547
 
548
                return new JsonModel($data);
549
            }
550
        } else {
551
            $data = [
552
                'success' => false,
553
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
554
            ];
555
 
556
            return new JsonModel($data);
557
        }
558
 
559
        return new JsonModel($data);
560
    }
561
 
1632 eleazar 562
    public function emailAction() {
1630 eleazar 563
        $request = $this->getRequest();
564
        $currentUserPlugin = $this->plugin('currentUserPlugin');
565
        $currentCompany = $currentUserPlugin->getCompany();
566
        $currentUser = $currentUserPlugin->getUser();
1640 eleazar 567
 
568
        $email = $request->getQuery('email');
1643 eleazar 569
 
570
        if(!$email){
571
            $data = [
572
                'success' => false,
573
                'data' => 'ERROR_INVALID_PARAMETER'
574
            ];
575
 
576
            return new JsonModel($data);
577
        }
578
 
579
        $userMapper = UserMapper::getInstance($this->adapter);
580
        $user = $userMapper->fetchOneByEmail($email);
581
 
582
        if (!$user) {
583
            return new JsonModel([
584
                'success' => false,
585
                'data' => 'ERROR_USER_NOT_FOUND',
586
            ]);
1644 eleazar 587
        } else if($request->isGet()){
588
            $data = [
589
                'success' => true,
590
                'data' => [
1663 eleazar 591
                    'user_id' => $user->id,
1644 eleazar 592
                    'first_name' => $user->first_name,
593
                    'last_name' => $user->last_name,
594
 
595
                ]
596
            ];
597
            return new JsonModel($data);
598
 
599
        }else {
600
            $data = [
1643 eleazar 601
                'success' => false,
1644 eleazar 602
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
603
            ];
604
 
605
            return new JsonModel($data);
1643 eleazar 606
        }
1630 eleazar 607
    }
1468 eleazar 608
}