1. Go to this page and download the library: Download laragear/preload 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/ */
laragear / preload example snippets
use Illuminate\Http\Request;
use Illuminate\Foundation\Application;
use Illuminate\Support\Lottery;
use Laragear\Preload\Facades\Preload;
return Application::configure()
->registered(function () {
Preload::condition(function (Request $request) {
if ($request->user()?->isAdmin()) {
return false;
}
return random_int(0, 100) === 50;
});
})->create();
use Illuminate\Support\Lottery;
use Laragear\Preload\Facades\Preload;
Preload::condition(function (Request $request) {
if ($request->user()?->isAdmin()) {
return false;
}
return Lottery::odds(2, 100);
});
use Laragear\Preload\Facades\Preload;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\Finder\Finder;
return Application::configure()
->booted(function () {
Preload::