1. Go to this page and download the library: Download rukhsar/addontraits 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/ */
rukhsar / addontraits example snippets
use Rukhsar\AddonTraits\OrderByTrait;
class User extends Model
{
use OrderByTrait;
protected $default_order_by = 'name';
protected $default_order_direction = 'asc';
}
$users = App\User::Order()->get();
use Rukhsar\AddonTraits\RandomModelTrait;
class User extends Model
{
use RandomModelTrait;
}
$randomUser = User::random()->first();
$randomUserWithRelation = User::random()->with('relation_name')->first();
// Static methods which return an instance
$user = User::getRandom(); // return instance or null
$user = User::getRandomOrFail(); // return instance or throw exception
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.