37 lines
871 B
PHP
37 lines
871 B
PHP
<?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;
|
|
}
|
|
}
|