Data Docter dan Hospital dnegan Filter di dashboard

This commit is contained in:
pajri
2022-12-16 15:57:40 +07:00
parent 1857653ce0
commit 0d6c2ab30b
20 changed files with 2680 additions and 80 deletions

View File

@@ -15,12 +15,22 @@ class OrganizationController extends Controller
* Display a listing of the resource.
* @return Renderable
*/
public function index()
public function index(Request $request)
{
$organizations = Organization::active()->hospital()->with('currentAddress')->paginate();
$organizations = Organization::hospital()->with('currentAddress')
->when($request->search ?? null, function ($query, $search) {
$query->where('name', 'LIKE', '%' . $search . '%');
})
->paginate();
return response()->json(Helper::paginateResources(OrganizationResource::collection($organizations)));
}
public function searchOrganization(Request $request)
{
$organizations = Organization::hospital()->get();
return response()->json(OrganizationResource::collection($organizations));
}
/**
* Show the form for creating a new resource.
* @return Renderable