PHP code example of eighteen73 / laravel-radioactivity
1. Go to this page and download the library: Download eighteen73/laravel-radioactivity 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/ */
eighteen73 / laravel-radioactivity example snippets
'models' => [
\App\Models\MyModel::class,
],
use Eighteen73\Radioactivity\Traits\HasEnergy;
class MyModel extends Model
{
use HasEnergy;
protected $appends = ['energy_amount'];
}
$model->addEnergy(); // Adds 1000 energy
$model->addEnergy(100); // Adds 100 energy
$model->energy->amount;
# Get Ordered Models by energy (DESC by default)
$orderedModels = MyModel::orderByEnergy('desc')->get();