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
use Illuminate\Database\Eloquent\Builder; // JANGAN LUPA INCLUDE ELOQUENT BUILDER | |
return view('some_view', [ | |
// LEMPAR QUERY SEARCH SEBELUMNYA | |
'search' => request()->search, | |
// MENGGUNAKAN FUNCTION WHEN, CHECK: https://laravel.com/docs/8.x/collections#method-when | |
// MENGGUNAKAN FUNCTION WHEREHAS, CHECK: https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence | |
'models' => Model::when(request()->search, function($qwr) { |