PHP code example of jayceedaily / laravel-traversify
1. Go to this page and download the library: Download jayceedaily/laravel-traversify 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/ */
jayceedaily / laravel-traversify example snippets
use Traversify/Traversify;
use Traversify/Traversable;
use Eloquent;
class Task extends Eloquent implements Traversable {
use Traversify;
// Configure the fields to be searched
protected $search = [
'name', 'description'
];
// Configure the fields to be sorted
protected $sort = [
'created_at', 'name', 'completed_at'
];
// Configure the fields to be filtered
protected $filter = [
'type_id', 'status'
];
}
use MyModel
class MyController {
public function index() {
return MyModel::traversify();
}
}
use Traversify/Traversify;
class MyModel {
use Traversify;
public static $searchables = ['title', 'description']
}
use Traversify/Traversify;
class MyModel {
use Traversify;
public static $filterables = ['status_id', 'is_active']
}
use Traversify/Traversify;
class MyModel {
use Traversify;
public static $orderables = ['created_at', 'is_active']
}
use Traversify/Traversify;
class MyModel {
use Traversify;
public static $rangables = ['created_at', 'price']
}
use MyModel;
class MyController {
public function index()
{
return MyModel::traversify(function($q){
$q->where('is_active', TRUE);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.