1. Go to this page and download the library: Download glhd/special 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/ */
glhd / special example snippets
use Glhd\Special\EloquentBacking;
enum SpecialOrganizations: string
{
use EloquentBacking;
#[CreateWith(['name' => 'Laravel', 'url' => 'https://laravel.com/'])]
case Laravel = 'laravel';
#[CreateWith(['name' => 'Spatie', 'url' => 'https://spatie.be/'])]
case Spatie = 'spatie';
#[CreateWith(['name' => 'Thunk', 'url' => 'http://thunk.dev/'])]
case Thunk = 'kathunk';
// If your enum name is the same as the model name, this is optional.
public static function modelClass(): string
{
return Organization::class;
}
}
// Get a copy of the model — only loads from DB once, but clones each time
SpecialOrganizations::Laravel->get();
// Get a single, shared copy — same instance each time
SpecialOrganizations::Laravel->singleton();
// Get a fresh copy — always loads from the DB
SpecialOrganizations::Laravel->fresh();
// Get a copy of the Laravel organization, which causes it to be
// cached for the rest of the request.
$laravel = SpecialOrganizations::Laravel->singleton();
assert($laravel->name === 'Laravel');
// Now we'll update it without using our enum
$org = Organizations::where('slug', 'laravel')->first();
$org->update(['name' => 'Laravel LLC']);
// Later calls to the enum will reflect the changes
$laravel = SpecialOrganizations::Laravel->singleton();
assert($laravel->name === 'Laravel LLC');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.