Last active
July 29, 2017 14:36
-
-
Save ridvanbaluyos/d05947fb2c965877e0ea60bf1faa8f05 to your computer and use it in GitHub Desktop.
helping someone in laravelph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Route | |
Route::get('/monitoring/{username}', 'MainCtr@monitoringView')->middleware('admin'); | |
// Controller | |
public function monitoringView($username = null) | |
{ | |
if (!is_null($username) || isset($username)) { | |
$data = Users::whereUsername($username)->first(); | |
} elseif (request()->has('monitoring')) { | |
$data = ServiceRequest::where('status', request('monitoring')) | |
->paginate(2) | |
->appends('monitoring', request('monitoring')); | |
} else { | |
$data = ServiceRequest::paginate(10); | |
} | |
return $view('page.monitoring')->with('data', $data); | |
} | |
// View | |
<div class="panel-body"> | |
<form> | |
<a href="/monitoring" class="btn btn-info">View All</a> | |
<a href="/monitoring?monitoring=2" class="btn btn-warning">View Pending</a> | |
<a href="/monitoring?monitoring=1" class="btn btn-success">View Completed</a> | |
<a href="/monitoring" class="btn btn-default">Sort Date</a> | |
</form> | |
<h3>{{ $data->total() }} total requests</h3> | |
<h3>{{ $user->username() }}</h3> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment