61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Repositories\Api\Access\Profession;
|
||
|
|
|
||
|
|
use App\Models\Profession;
|
||
|
|
use App\Constant\Constant;
|
||
|
|
use Illuminate\Support\Facades\Log;
|
||
|
|
use App\Repositories\Api\Access\Profession\ProfessionInterface;
|
||
|
|
|
||
|
|
class ProfessionRepository implements ProfessionInterface
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var Profession
|
||
|
|
*/
|
||
|
|
protected $profession;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param Profession $profession
|
||
|
|
* ProfessionRepository constructor.
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
public function __construct(Profession $profession)
|
||
|
|
{
|
||
|
|
$this->profession = $profession;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function index($data)
|
||
|
|
{
|
||
|
|
$response = [];
|
||
|
|
|
||
|
|
try {
|
||
|
|
$professionData = $this->profession;
|
||
|
|
|
||
|
|
if (isset($data['name']) && !empty($data['name'])) {
|
||
|
|
$professionData = $professionData->where('name', 'LIKE', "%{$data['name']}%");
|
||
|
|
}
|
||
|
|
|
||
|
|
$professionData = $professionData->get()->toArray();
|
||
|
|
|
||
|
|
if ($professionData) {
|
||
|
|
$response['data'] = $professionData;
|
||
|
|
$response['status'] = Constant::CODE_200;
|
||
|
|
} else {
|
||
|
|
$response['data'] = [];
|
||
|
|
$response['status'] = Constant::CODE_401;
|
||
|
|
}
|
||
|
|
|
||
|
|
} catch (\Exception $ex) {
|
||
|
|
Log::error($ex);
|
||
|
|
$response['message'] = trans('auth.something_went_wrong');
|
||
|
|
$response['status'] = Constant::CODE_403;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|