PHP code example of yomafleet / laravel-feature-flag
1. Go to this page and download the library: Download yomafleet/laravel-feature-flag 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/ */
namespace App\Models;
use Yomafleet\FeatureFlag\UserContract;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements UserContract
{
/**
* Get ID of the user.
*
* @return string|integer
*/
public function id(): string|int
{
return $this->id;
}
/**
* Get all roles of the user.
*
* @return array
*/
public function roles(): array
{
return $this->roles->toArray();
}
/**
* Check if the user has given role.
*
* @param string $name
* @return boolean
*/
public function hasRole(string $name): bool
{
return $this->hasRole($name);
}
}
use Yomafleet\FeatureFlag\Facade as Flag;
//...
//...
//...
$isEnabled = Flag::enabled('someflag-check');