Feature #5 : Activate Filter Button on Table on Each Module Location
This commit is contained in:
@@ -17,7 +17,8 @@ class CitiesController extends Controller
|
||||
public $user;
|
||||
|
||||
public function index(){
|
||||
return view('location::cities.index');
|
||||
$provinces = Province::all();
|
||||
return view('location::cities.index', compact('provinces'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
@@ -78,10 +79,14 @@ class CitiesController extends Controller
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$search = explode('|', $search);
|
||||
if(isset($search[0]) &&!empty($search[0])){
|
||||
$query->where('province_code',$search[0]);
|
||||
}
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
$q->orWhereRelation('province','name', 'LIKE', "%$search%");
|
||||
$q->where('code', 'LIKE', "%$search[1]%");
|
||||
$q->orWhere('name', 'LIKE', "%$search[1]%");
|
||||
$q->orWhereRelation('province','name', 'LIKE', "%$search[1]%");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +113,7 @@ class CitiesController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$cities = $query->with('province')->get();
|
||||
$data = $query->with('province')->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords/$request->get('size'));
|
||||
@@ -124,7 +129,7 @@ class CitiesController extends Controller
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $cities,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ class DistrictsController extends Controller
|
||||
public $user;
|
||||
|
||||
public function index(){
|
||||
return view('location::districts.index');
|
||||
$provinces = Province::all();
|
||||
return view('location::districts.index', compact('provinces'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
@@ -78,11 +79,16 @@ class DistrictsController extends Controller
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$search = explode('|', $search);
|
||||
if(isset($search[0]) &&!empty($search[0])){
|
||||
$query->where('province_code',$search[0]);
|
||||
}
|
||||
if(isset($search[1]) &&!empty($search[1])){
|
||||
$query->where('city_code',$search[1]);
|
||||
}
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
$q->orWhereRelation('city','name', 'LIKE', "%$search%");
|
||||
$q->orWhereRelation('city.province','name', 'LIKE', "%$search%");
|
||||
$q->where('code', 'LIKE', "%$search[2]%");
|
||||
$q->orWhere('name', 'LIKE', "%$search[2]%");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,7 +115,7 @@ class DistrictsController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$cities = $query->with('city.province')->get();
|
||||
$data = $query->with('city.province')->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords/$request->get('size'));
|
||||
@@ -125,7 +131,7 @@ class DistrictsController extends Controller
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $cities,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Location\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('location::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('location::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('location::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('location::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class ProvincesController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$provinces = $query->get();
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords/$request->get('size'));
|
||||
@@ -123,7 +123,7 @@ class ProvincesController extends Controller
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $provinces,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user