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 ...@@ -46,6 +46,26 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $exception) 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); 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 ...@@ -34,7 +34,7 @@ class SearchController extends Controller
$apiLocaterData = $this->call_api_page($api_url, $locality, $state, $city, $location, $ratingOrder, $page); $apiLocaterData = $this->call_api_page($api_url, $locality, $state, $city, $location, $ratingOrder, $page);
if ( count($apiLocaterData['data']) < 1 ) 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'); $locaterIds = collect($apiLocaterData['data'])->pluck('id');
...@@ -58,51 +58,38 @@ class SearchController extends Controller ...@@ -58,51 +58,38 @@ class SearchController extends Controller
return $data; return $data;
}, $apiLocaterData['data']); }, $apiLocaterData['data']);
$links = $apiLocaterData['links'];
$meta = $apiLocaterData['meta'];
$data = array(); $data = array();
$data['finalData'] = $finalData; $data['finalData'] = $finalData;
$data['links'] = $links; $data['links'] = $apiLocaterData['links'];
$data['meta'] = $meta; $data['meta'] = $apiLocaterData['meta'];
return response()->json([ return [
'status' => 'success', 'status' => 'success',
'data' => $data '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) public function index(Request $request)
{ {
$detail = $this->getApiData(); $final = $this->getApiData();
$final = $detail->original;
if($final['status'] == 'success'){ if($final['status'] == 'success'){
$finalData = $final['data']['finalData']; $finalData = $final['data']['finalData'];
$links = $final['data']['links']; $links = $final['data']['links'];
$meta = $final['data']['meta']; $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) public function searchlocater(Request $request)
{ {
$detail = $this->getApiData($request['locality'], $request['state'], $request['city'], $request['location'], $request['ratingOrder'], $request['page']); $final = $this->getApiData($request['locality'], $request['state'], $request['city'], $request['location'], $request['ratingOrder'], $request['page']);
$final = $detail->original;
if($final['status'] == 'success'){ if($final['status'] == 'success'){
...@@ -110,30 +97,14 @@ class SearchController extends Controller ...@@ -110,30 +97,14 @@ class SearchController extends Controller
$links = $final['data']['links']; $links = $final['data']['links'];
$meta = $final['data']['meta']; $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(); $html = view('frontend.searchs.location_element', compact('finalData', 'links', 'meta'))->render();
return response()->json(['status' => 'error', 'data' => $html]); return ['status' => 'success', 'data' => $html];
} }
}
/**
* For render detail page
* */
public function detail(Request $request, $slug) public function detail(Request $request, $slug)
{ {
$pageData = Page::where('pages.slug', '=', $slug) $pageData = Page::where('pages.slug', '=', $slug)
...@@ -142,6 +113,8 @@ class SearchController extends Controller ...@@ -142,6 +113,8 @@ class SearchController extends Controller
})) }))
->first(); ->first();
if(!empty($pageData)){
/*Fetch Locater ID*/ /*Fetch Locater ID*/
$locatorID = $pageData->locaterlists->locater_identity; $locatorID = $pageData->locaterlists->locater_identity;
...@@ -150,6 +123,12 @@ class SearchController extends Controller ...@@ -150,6 +123,12 @@ class SearchController extends Controller
$homepage = Homepage::where('homepages.status', '=', '1')->first(); $homepage = Homepage::where('homepages.status', '=', '1')->first();
return view('frontend.searchs.detail', compact('homepage','locatorID','locationDetailAPIdata','pageData')); return view('frontend.searchs.detail', compact('homepage','locatorID','locationDetailAPIdata','pageData'));
}else{
return view('errors.404');
}
} }
...@@ -159,59 +138,37 @@ class SearchController extends Controller ...@@ -159,59 +138,37 @@ class SearchController extends Controller
$api_url = config('app.api_search'); $api_url = config('app.api_search');
$locationDetailAPIdata = $this->call_api_page($api_url,$request['query']); $locationDetailAPIdata = $this->call_api_page($api_url,$request['query']);
if(empty($locationDetailAPIdata['data'])){
$html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render(); $html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render();
return response()->json([ return [
'status' => 'error',
'data' => $html
]);
}else{
$html = view('frontend.searchs.autocomplete', compact('locationDetailAPIdata'))->render();
return response()->json([
'status' => 'success', 'status' => 'success',
'data' => $html 'data' => $html
]); ];
}
} }
/** public function reviewPaginate(Request $request)
* For render Review ajax
* */
public function reviewpaginate(Request $request)
{ {
$api_url = config('app.api'); $api_url = config('app.api');
$reviewData = $this->review_api_detail($api_url,$request->locatorID,$request->page); $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')); return view('frontend.searchs.review_element', compact('reviewData'));
} }
public function getCityValue(Request $request) 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)
if(!empty($getCityData)){ ->where('cities.is_deleted', '=', '0')
->where('cities.status', '=', '1')
->pluck('name','id')->toarray();
$html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render(); $html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render();
return response()->json([ return [
'status' => 'success', 'status' => 'success',
'data' => $html 'data' => $html
]); ];
}else{
$html = view('frontend.searchs.city_dropdown', compact('getCityData'))->render();
return response()->json(['status' => 'error', '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 @@ ...@@ -6,6 +6,6 @@
</ul> </ul>
@else @else
<ul class="dropdown-menu" style="display:block; position:relative"> <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> </ul>
@endif @endif
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
<option value="">Select City</option> <option value="">Select City</option>
@if(!empty($getCityData)) @if(!empty($getCityData))
@foreach($getCityData as $key => $option) @foreach($getCityData as $key => $option)
<option value="<?php echo $option; ?>"><?php echo $option; ?> <option value="<?php echo $option; ?>"><?php echo $option; ?></option>
</option>
@endforeach @endforeach
@endif @endif
</select> </select>
\ No newline at end of file
...@@ -270,13 +270,13 @@ ...@@ -270,13 +270,13 @@
$("#reviewElement").on('click','.pagination li a',function () { $("#reviewElement").on('click','.pagination li a',function () {
var page = $(this).data('page'); var page = $(this).data('page');
var locatorID = $('#locaterid').val(); var locatorID = $('#locaterid').val();
reviewpaginate(page,locatorID); reviewPaginate(page,locatorID);
}); });
function reviewpaginate(page,locatorID){ function reviewPaginate(page,locatorID){
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: "{{route('reviewpaginate')}}", url: "{{route('reviewPaginate')}}",
data: {"_token": "{{ csrf_token() }}",page:page,locatorID:locatorID}, data: {"_token": "{{ csrf_token() }}",page:page,locatorID:locatorID},
success: function (datanew) { success: function (datanew) {
$( "#reviewElement" ).html( datanew ); $( "#reviewElement" ).html( datanew );
......
...@@ -79,9 +79,6 @@ ...@@ -79,9 +79,6 @@
if(data.status == 'success') { if(data.status == 'success') {
$('#localitylist').fadeIn(); $('#localitylist').fadeIn();
$('#localitylist').html(data.data); $('#localitylist').html(data.data);
} else {
$('#localitylist').fadeIn();
$('#localitylist').html(data.data);
} }
} }
}) })
...@@ -152,18 +149,9 @@ ...@@ -152,18 +149,9 @@
data: {"_token": "{{ csrf_token() }}",page:page,locality:locality,state:state,city:city,location:location,ratingOrder:ratingOrder}, data: {"_token": "{{ csrf_token() }}",page:page,locality:locality,state:state,city:city,location:location,ratingOrder:ratingOrder},
success: function (datanew) { success: function (datanew) {
if(datanew.status == 'success') {
loader();
$('#searchlocaterid').html(datanew.data);
} else {
loader(); loader();
$('#searchlocaterid').html(datanew.data); $('#searchlocaterid').html(datanew.data);
} }
$(".locality").val(locality);
$('.getStateValue option:selected').attr('state');
$(".getCityValue").val(city);
$('.location').val(location);
}
}); });
} }
...@@ -176,11 +164,7 @@ ...@@ -176,11 +164,7 @@
url: "{{route('getCityValue')}}", url: "{{route('getCityValue')}}",
data: {"_token": "{{ csrf_token() }}",state:state}, data: {"_token": "{{ csrf_token() }}",state:state},
success: function (datanew) { success: function (datanew) {
if(datanew.status == 'success') {
$('.cityData').html(datanew.data); $('.cityData').html(datanew.data);
} else {
$('.cityData').html(datanew.data);
}
} }
}); });
}); });
...@@ -189,7 +173,7 @@ ...@@ -189,7 +173,7 @@
function loader(){ function loader(){
if ($('.loader-outer-box').length) { if ($('.loader-outer-box').length) {
$('.loader-outer-box').fadeIn('slow', function () { $('.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"> <div class="col-12 card-columns">
@foreach($reviewData['data'] as $data) @foreach($reviewData['data'] as $data)
<article class="card"> <article class="card">
...@@ -71,3 +72,12 @@ ...@@ -71,3 +72,12 @@
</article> </article>
@endif @endif
</div> </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'); ...@@ -19,13 +19,17 @@ Route::get('/', 'SearchController@index')->name('search');
Route::post('searchlocater', 'SearchController@searchlocater')->name('searchlocater'); Route::post('searchlocater', 'SearchController@searchlocater')->name('searchlocater');
Route::get('autocomplete', 'SearchController@autocomplete')->name('autocomplete'); Route::get('autocomplete', 'SearchController@autocomplete')->name('autocomplete');
Route::get('detail/{slug}', 'SearchController@detail')->name('detail'); 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'); Route::post('getCityValue', 'SearchController@getCityValue')->name('getCityValue');
/* Cron Routes */ /* Cron Routes */
Route::get('cron/getLocaterListData', 'CronController@getLocaterListData')->name('getLocaterListData'); Route::get('cron/getLocaterListData', 'CronController@getLocaterListData')->name('getLocaterListData');
Route::get('cron/getState', 'CronController@getState')->name('getState'); Route::get('cron/getState', 'CronController@getState')->name('getState');
Route::get('cron/getCity', 'CronController@getCity')->name('getCity'); 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 */ /** End Cron Routes */
Auth::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