Commit b5b0ddbb by Arpit Jain

Completed project review point and also add 404 and 405 page

parent c683e06c
......@@ -46,6 +46,26 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if($this->isHttpException($exception)){
switch ($exception->getStatusCode()) {
case 404:
return redirect()->route('404');
break;
case 405:
return redirect()->route('405');
break;
}
}
return parent::render($request, $exception);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ErrorHandlerController extends Controller
{
public function errorCode404()
{
return view('errors.404');
}
public function errorCode405()
{
return view('errors.405');
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ class SearchController extends Controller
$apiLocaterData = $this->call_api_page($api_url, $locality, $state, $city, $location, $ratingOrder, $page);
if ( count($apiLocaterData['data']) < 1 )
return response()->json(['status' => 'error', 'data' => 'No data found!']);
return ['status' => 'error', 'data' => 'No data found!'];
$locaterIds = collect($apiLocaterData['data'])->pluck('id');
......@@ -58,82 +58,53 @@ class SearchController extends Controller
return $data;
}, $apiLocaterData['data']);
$links = $apiLocaterData['links'];
$meta = $apiLocaterData['meta'];
$data = array();
$data['finalData'] = $finalData;
$data['links'] = $links;
$data['meta'] = $meta;
return response()->json([
$data['links'] = $apiLocaterData['links'];
$data['meta'] = $apiLocaterData['meta'];
return [
'status' => 'success',
'data' => $data
]);
];
}
/**
* For Rendring index page first time and FetchData in DataBase and ApiData then Match both Data Then show final array with slug
*
* */
public function index(Request $request)
{
$detail = $this->getApiData();
$final = $detail->original;
$final = $this->getApiData();
if($final['status'] == 'success'){
$finalData = $final['data']['finalData'];
$links = $final['data']['links'];
$meta = $final['data']['meta'];
$getState = City::where('type', '=', '2')->get()->toarray();
return view('frontend.searchs.index', compact('finalData','links','meta','getState'));
}else{
return response()->json(['status' => 'error', 'data' => 'No data found!']);
}
$getState = City::where('type', '=', '2')->get()->toarray();
return view('frontend.searchs.index', compact('finalData','links','meta','getState'));
}
/**
* For render location list after searching
* */
public function searchlocater(Request $request)
{
$detail = $this->getApiData($request['locality'], $request['state'], $request['city'], $request['location'], $request['ratingOrder'], $request['page']);
$final = $detail->original;
$final = $this->getApiData($request['locality'], $request['state'], $request['city'], $request['location'], $request['ratingOrder'], $request['page']);
if($final['status'] == 'success'){
$finalData = $final['data']['finalData'];
$links = $final['data']['links'];
$meta = $final['data']['meta'];
$locality = $request->locality;
$state = $request->state;
$city = $request->city;
$location = $request->location;
$ratingOrder = $request->ratingOrder;
$html = view('frontend.searchs.location_element', compact('finalData', 'links', 'locality','state','city', 'location', 'ratingOrder', 'meta'))->render();
return response()->json([
'status' => 'success',
'data' => $html
]);
}else{
}
$html = view('frontend.searchs.location_element', compact('finalData', 'links', 'locality','state','city', 'location', 'meta'))->render();
return response()->json(['status' => 'error', 'data' => $html]);
$html = view('frontend.searchs.location_element', compact('finalData', 'links', 'meta'))->render();
return ['status' => 'success', 'data' => $html];
}
}
/**
* For render detail page
* */
public function detail(Request $request, $slug)
{
$pageData = Page::where('pages.slug', '=', $slug)
......@@ -142,14 +113,22 @@ class SearchController extends Controller
}))
->first();
/*Fetch Locater ID*/
$locatorID = $pageData->locaterlists->locater_identity;
if(!empty($pageData)){
$api_url = config('app.api_location');
$locationDetailAPIdata = $this->call_api($api_url,$locatorID);
$homepage = Homepage::where('homepages.status', '=', '1')->first();
return view('frontend.searchs.detail', compact('homepage','locatorID','locationDetailAPIdata','pageData'));
/*Fetch Locater ID*/
$locatorID = $pageData->locaterlists->locater_identity;
$api_url = config('app.api_location');
$locationDetailAPIdata = $this->call_api($api_url,$locatorID);
$homepage = Homepage::where('homepages.status', '=', '1')->first();
return view('frontend.searchs.detail', compact('homepage','locatorID','locationDetailAPIdata','pageData'));
}else{
return view('errors.404');
}
}
......@@ -159,36 +138,19 @@ class SearchController extends Controller
$api_url = config('app.api_search');
$locationDetailAPIdata = $this->call_api_page($api_url,$request['query']);
if(empty($locationDetailAPIdata['data'])){
$html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render();
return response()->json([
'status' => 'error',
'data' => $html
]);
}else{
$html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render();
return response()->json([
'status' => 'success',
'data' => $html
]);
}
$html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render();
return [
'status' => 'success',
'data' => $html
];
}
/**
* For render Review ajax
* */
public function reviewpaginate(Request $request)
public function reviewPaginate(Request $request)
{
$api_url = config('app.api');
$reviewData = $this->review_api_detail($api_url,$request->locatorID,$request->page);
if ( count($reviewData['data']) < 1 ) return '';
return view('frontend.searchs.review_element', compact('reviewData'));
}
......@@ -196,22 +158,17 @@ class SearchController extends Controller
public function getCityValue(Request $request)
{
$getCityData = City::where('cities.name', '!=', '')->where('cities.parent_id', '=', $request->state)->pluck('name','id')->toarray();
$getCityData = City::where('cities.name', '!=', '')
->where('cities.parent_id', '=', $request->state)
->where('cities.is_deleted', '=', '0')
->where('cities.status', '=', '1')
->pluck('name','id')->toarray();
if(!empty($getCityData)){
$html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render();
return response()->json([
'status' => 'success',
'data' => $html
]);
}else{
$html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render();
return response()->json(['status' => 'error', 'data' => $html]);
}
$html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render();
return [
'status' => 'success',
'data' => $html
];
}
}
<!DOCTYPE html>
<html>
<head>
<title>404 Page Not Found Error</title>
</head>
<body>
<h1>Sorry, Page Not Found 404</h1>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>405 Page Not Found Error</title>
</head>
<body>
<h1>Sorry, Page Not Found 405</h1>
</body>
</html>
\ No newline at end of file
......@@ -6,6 +6,6 @@
</ul>
@else
<ul class="dropdown-menu" style="display:block; position:relative">
<li><i class="mdi mdi-map-marker"></i><a href="javascript:void(0);"></a>No data found!</li>
<li><i class="mdi mdi-map-marker"></i><a href="javascript:void(0);">No data found!</a></li>
</ul>
@endif
......@@ -2,8 +2,7 @@
<option value="">Select City</option>
@if(!empty($getCityData))
@foreach($getCityData as $key => $option)
<option value="<?php echo $option; ?>"><?php echo $option; ?>
</option>
<option value="<?php echo $option; ?>"><?php echo $option; ?></option>
@endforeach
@endif
</select>
\ No newline at end of file
......@@ -270,13 +270,13 @@
$("#reviewElement").on('click','.pagination li a',function () {
var page = $(this).data('page');
var locatorID = $('#locaterid').val();
reviewpaginate(page,locatorID);
reviewPaginate(page,locatorID);
});
function reviewpaginate(page,locatorID){
function reviewPaginate(page,locatorID){
$.ajax({
type: 'post',
url: "{{route('reviewpaginate')}}",
url: "{{route('reviewPaginate')}}",
data: {"_token": "{{ csrf_token() }}",page:page,locatorID:locatorID},
success: function (datanew) {
$( "#reviewElement" ).html( datanew );
......
......@@ -79,10 +79,7 @@
if(data.status == 'success') {
$('#localitylist').fadeIn();
$('#localitylist').html(data.data);
} else {
$('#localitylist').fadeIn();
$('#localitylist').html(data.data);
}
}
}
})
}
......@@ -151,18 +148,9 @@
url: "{{route('searchlocater')}}",
data: {"_token": "{{ csrf_token() }}",page:page,locality:locality,state:state,city:city,location:location,ratingOrder:ratingOrder},
success: function (datanew) {
if(datanew.status == 'success') {
loader();
$('#searchlocaterid').html(datanew.data);
} else {
loader();
$('#searchlocaterid').html(datanew.data);
}
$(".locality").val(locality);
$('.getStateValue option:selected').attr('state');
$(".getCityValue").val(city);
$('.location').val(location);
loader();
$('#searchlocaterid').html(datanew.data);
}
});
}
......@@ -176,11 +164,7 @@
url: "{{route('getCityValue')}}",
data: {"_token": "{{ csrf_token() }}",state:state},
success: function (datanew) {
if(datanew.status == 'success') {
$('.cityData').html(datanew.data);
} else {
$('.cityData').html(datanew.data);
}
$('.cityData').html(datanew.data);
}
});
});
......@@ -189,7 +173,7 @@
function loader(){
if ($('.loader-outer-box').length) {
$('.loader-outer-box').fadeIn('slow', function () {
setTimeout(function(){ $('.loader-outer-box').fadeOut('slow'); }, 2000);
setTimeout(function(){ $('.loader-outer-box').fadeOut('slow'); });
});
}
}
......
@if(!empty($reviewData['data']))
<div class="col-12 card-columns">
@foreach($reviewData['data'] as $data)
<article class="card">
......@@ -70,4 +71,13 @@
<!-- End Pagination -->
</article>
@endif
</div>
\ No newline at end of file
</div>
@else
<div class="col-12 card-columns">
<article class="card">
<div class="card-body">
<p class="rev-text">No Data Found!</p>
</div>
</article>
</div>
@endif
\ No newline at end of file
......@@ -19,13 +19,17 @@ Route::get('/', 'SearchController@index')->name('search');
Route::post('searchlocater', 'SearchController@searchlocater')->name('searchlocater');
Route::get('autocomplete', 'SearchController@autocomplete')->name('autocomplete');
Route::get('detail/{slug}', 'SearchController@detail')->name('detail');
Route::post('reviewpaginate', 'SearchController@reviewpaginate')->name('reviewpaginate');
Route::post('reviewPaginate', 'SearchController@reviewPaginate')->name('reviewPaginate');
Route::post('getCityValue', 'SearchController@getCityValue')->name('getCityValue');
/* Cron Routes */
Route::get('cron/getLocaterListData', 'CronController@getLocaterListData')->name('getLocaterListData');
Route::get('cron/getState', 'CronController@getState')->name('getState');
Route::get('cron/getCity', 'CronController@getCity')->name('getCity');
Route::get('404',['as'=>'404','uses'=>'ErrorHandlerController@errorCode404']);
Route::get('405',['as'=>'405','uses'=>'ErrorHandlerController@errorCode405']);
/** End Cron Routes */
Auth::routes();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment