api code global jain
This commit is contained in:
36
app/Repositories/Api/Access/Hospital/HospitalRepository.php
Normal file
36
app/Repositories/Api/Access/Hospital/HospitalRepository.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Api\Access\Hospital;
|
||||
|
||||
use App\Constant\Constant;
|
||||
use App\Models\Hospital;
|
||||
|
||||
class HospitalRepository
|
||||
{
|
||||
public function __construct(protected Hospital $hospital)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAll() : array
|
||||
{
|
||||
$result = $this->hospital->query()
|
||||
->where('status',1)
|
||||
->select('id','name','area', 'city')
|
||||
->orderBy('name','asc')
|
||||
->get()->map(function ($items) {
|
||||
$items['id'] = $items->id;
|
||||
$items['name'] = $items->name;
|
||||
$items['area'] = $items?->area;
|
||||
$items['city'] = $items?->city;
|
||||
return $items;
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$response['data'] = $result;
|
||||
$response['status'] = Constant::CODE_200;
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user