Last active
February 22, 2019 09:01
-
-
Save renton18/01b7c3b8172706b517bde327c270fbc8 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace App\Http\Controllers; | |
use App\Models\problem; | |
use Illuminate\Http\Request; | |
use Models; | |
class ProblemController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index(Request $request) | |
{ | |
$query = problem::query(); | |
$problemId = $request-> problemId; | |
$problemCategory = $request->problemCategory; | |
if (!empty($problemId)) { | |
$query->Where('problemID', 'like', '%'. $problemId.'%') ; | |
} | |
if (!empty($problemCategory)) { | |
$query->orWhere('problemCategory', 'like', '%'. $problemCategory.'%') ; | |
} | |
$problems = $query->orderBy('problemId', 'desc')->paginate(10); | |
return view('problem.index', [ 'problems' => $problems, 'request' => $request]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment