PHP code example of morfin / querystring-for-laravel
1. Go to this page and download the library: Download morfin/querystring-for-laravel 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/ */
protected $filters = ['all_except'];
public function all_except($query, $value) {
return $query->where('name', '!=', $value);
}
protected $filters = ['in'];
public function in($query, $value) {
$exploded = explode(',', $value);
if(count($exploded) != 4) {
// throwing an exception or whatever you like to do
}
$field = array_shift($exploded);
return $query->whereIn($field, $exploded);
}
protected $filters = ['by'];
public function by($query, $value) {
return $query->where('username', $value);
}
User::filter('in')->get();
User::filter('like', 'name')->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.