1. Go to this page and download the library: Download calhoun/eloquent-otf 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/ */
calhoun / eloquent-otf example snippets
$data = [
[
'id' => 1
'first' => 'Maurice',
'last' => 'Calhoun',
'email' => '[email protected]',
'age' => '40',
'manager_id' => 2
],
[
'id' => 2
'first' => 'John',
'last' => 'Doe',
'email' => '[email protected]',
'age' => '45',
'manager_id' => null
],
...
];
$result = eloquent($data, function($query){
return $query->whereAge(40)->get();
});
// You can pass a third parameter for the table name (by default the name is oft)
$result = eloquent($data, function($query, $name){
return $query->join($name . " as manager", $name.'.manager_id', '=', 'manager.id')->find(1);
}, 'employees');