1. Go to this page and download the library: Download alexmg86/laravel-sub-query 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/ */
alexmg86 / laravel-sub-query example snippets
use Alexmg86\LaravelSubQuery\Traits\LaravelSubQueryTrait;
use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
use LaravelSubQueryTrait;
// Get a the first user's posts and remember them for a day.
Invoice::withSum('items:price')->remember(now()->addDay())->posts()->get();
// You can also pass the number of seconds if you like
// (before Laravel 5.8 this will be interpreted as minutes).
Invoice::withSum('items:price')->remember(60 * 60 * 24)->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.