PHP code example of yogameleniawan / search-sort-eloquent
1. Go to this page and download the library: Download yogameleniawan/search-sort-eloquent library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yogameleniawan / search-sort-eloquent example snippets
return [
App\Providers\AppServiceProvider::class,
...
Yogameleniawan\SearchSortEloquent\SearchSortServiceProvider::class, // add this line
];
'providers' => [
...
Yogameleniawan\SearchSortEloquent\SearchSortServiceProvider::class, // add this line
]
use Yogameleniawan\SearchSortEloquent\Traits\Searchable;
class User extends Model {
use Searchable;
....
}
class UserController extends Controller {
public function search(Request $request) {
$user = User::search(
keyword: $request->keyword,
columns: ["id", "name", "email"],
)->get();
dd($user);
}
}
use Yogameleniawan\SearchSortEloquent\Traits\Sortable;
class User extends Model {
use Sortable;
....
}
class UserController extends Controller {
public function sort(Request $request) {
$user = User::sort(
sort_by: $request->sort_by,
sort_order: $request->sort_order
)->get();
dd($user);
}
}
class UserController extends Controller {
public function sort(Request $request) {
$user = User::search(
keyword: $request->keyword,
columns: ["id", "name", "email"],
)->sort(
sort_by: $request->sort_by,
sort_order: $request->sort_order
)->get();
dd($user);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.