PHP code example of activix / simple-eloquent
1. Go to this page and download the library: Download activix/simple-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/ */
activix / simple-eloquent example snippets
use Volosyuk\SimpleEloquent\SimpleEloquent;
class Department extends \Illuminate\Database\Eloquent\Model
{
use SimpleEloquent;
}
$users = User::whereHas('units')->withCount('units')->with('units')->limit(10)->simple()->get();
$activeUser = User::simple()->where('is_active', 1)->first();
$users = User::with([
'units.leaders.performance',
'teams.leaders.performance',
'programs.courses'
])->limit(50)->get()
$goals = Goal::with('goalUser.user.courses.points.user')->limit(20)->get()
$performance = Performance::whereHas('user')->with('goal.goalUser')->limit(1000)->get()
$categories = Category::with('articles')->get() // want to grab all categories with articles
Illuminate\Database\Eloquent\Collection::__set_state([
'items' => [
0 => Category::__set_state([
'guarded' => [],
'connection' => 'default',
'table' => NULL,
'primaryKey' => 'id',
'keyType' => 'int',
'incrementing' => true,
'with' => [],
'withCount' => [],
'perPage' => 15,
'exists' => true,
'wasRecentlyCreated' => false,
'attributes' => [
'id' => '1',
'name' => 'Test category',
'created_at' => '2017-12-21 12:33:34',
'updated_at' => '2017-12-21 12:33:34'
],
'original' => [
'id' => '1',
'name' => 'Test category',
'created_at' => '2017-12-21 12:33:34',
'updated_at' => '2017-12-21 12:33:34',
],
'changes' => [],
'casts' => [],
'dates' => [],
'dateFormat' => NULL,
'appends' => [],
'dispatchesEvents' => [],
'observables' => [],
'relations' => [
'articles' => Illuminate\Database\Eloquent\Collection::__set_state([
'items' => [
0 => Article::__set_state([
'guarded' => [],
'connection' => 'default',
'table' => NULL,
'primaryKey' => 'id',
'keyType' => 'int',
'incrementing' => true,
'with' => [],
'withCount' => [],
'perPage' => 15,
'exists' => true,
'wasRecentlyCreated' => false,
'attributes' => [
'id' => '1',
'category_id' => '1',
'title' => 'Test article',
'created_at' => '2017-12-21 12:33:34',
'updated_at' => '2017-12-21 12:33:34',
],
'original' => [
'id' => '1',
'category_id' => '1',
'title' => 'Test article',
'created_at' => '2017-12-21 12:33:34',
'updated_at' => '2017-12-21 12:33:34',
],
'changes' => [],
'casts' => [],
'dates' => [],
'dateFormat' => NULL,
'appends' => [],
'dispatchesEvents' => [],
'observables' => [],
'relations' => [],
'touches' => [],
'timestamps' => true,
'hidden' => [],
'visible' => [],
'fillable' => [],
]),
],
]),
],
'touches' => [],
'timestamps' => true,
'hidden' => [],
'visible' => [],
'fillable' => [],
])
]
]);
Illuminate\Support\Collection::__set_state([
'items' => [
0 => stdClass::__set_state([
'id' => '1',
'name' => 'Test category',
'created_at' => '2017-12-21 12:43:44',
'updated_at' => '2017-12-21 12:43:44',
'articles' => Illuminate\Support\Collection::__set_state([
'items' => [
0 => stdClass::__set_state([
'id' => '1',
'category_id' => '1',
'title' => 'Test article',
'created_at' => '2017-12-21 12:43:44',
'updated_at' => '2017-12-21 12:43:44',
]),
],
]),
]),
]
]);