PHP code example of reinink / advanced-eloquent

1. Go to this page and download the library: Download reinink/advanced-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/ */

    

reinink / advanced-eloquent example snippets


$users = User::addSubSelect('last_login_at', Login::select('created_at')
    ->whereColumn('user_id', 'users.id')
    ->latest()
)->get();

$users = DB::table('users')->addSubSelect('last_login_at', DB::table('logins')
    ->select('created_at')
    ->whereColumn('user_id', 'users.id')
    ->latest()
)->get()

$users = User::orderBySub(Company::select('name')->whereColumn('company_id', 'companies.id'))->get();

$users = User::addSubSelect('last_login_at', Login::select('created_at')
        ->whereColumn('user_id', 'users.id')
        ->latest()
    )->orderBySubDesc(Login::select('created_at')
        ->whereColumn('user_id', 'users.id')
        ->latest(), 'last'
    )->get();