5 lines
586 B
PHP
5 lines
586 B
PHP
<?php
|
|
namespace Modules\Search\Http\Controllers;
|
|
use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB;
|
|
final class SearchController extends Controller { public function index(Request $request){ $q=trim((string)$request->query('q')); $results=DB::table('search_index')->when($q!== '',fn($query)=>$query->where(fn($w)=>$w->where('title','like',"%{$q}%")->orWhere('summary','like',"%{$q}%")->orWhere('content','like',"%{$q}%")))->latest('updated_at')->paginate(25)->withQueryString(); return view('search::index',compact('results','q')); } }
|