1. Go to this page and download the library: Download divineomega/thisishowirole 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/ */
divineomega / thisishowirole example snippets
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateThisIsHowIRoleRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tihir_roles', function (Blueprint $table) {
$table->increments('id');
$table->string('class_name');
$table->bigInteger('foreign_id');
$table->text('roles');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('tihir_roles');
}
}
use DivineOmega\ThisIsHowIRole\RolesTrait as Roles; // <-- Line 1
class User
{
use Roles; // <-- Line 2
public $id = 123;
}
$user = new User;
$user->roles->add('can_eat_cake');
$user->roles->add('can_eat_cookies');
$user->roles->remove('can_eat_cookies');
echo 'This user can ';
if ($user->roles->has('can_eat_cake')) {
echo 'eat cakes... ';
}
if ($user->roles->has('can_eat_cookies')) {
echo 'eat cookies... ';
}
echo "\n";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.