Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.