PHP code example of yuriy-martini / laravel-authorization
1. Go to this page and download the library: Download yuriy-martini/laravel-authorization 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/ */
yuriy-martini / laravel-authorization example snippets
namespace App\Models;
class User
implements \YuriyMartini\Laravel\Authorization\Contracts\Authorizable
{
use \YuriyMartini\Laravel\Authorization\Concerns\Authorizable;
}
namespace App\Models\User;
trait Authorizations
{
public function isViewable(Authorizable $user): bool
{
return true; // here: ur BL
}
public function isUpdatable(Authorizable $user): bool
{
return true; // here: ur BL
}
public function isDeletable(Authorizable $user): bool
{
return true; // here: ur BL
}
public function isRestorable(Authorizable $user): bool
{
return true; // here: ur BL
}
public function isForceDeletable(Authorizable $user): bool
{
return true; // here: ur BL
}
}
namespace App\Models;
class User
implements \YuriyMartini\Laravel\Authorization\Contracts\Model
{
use \App\Models\User\Authorizations;
}
namespace App\Policies;
class UserPolicy
extends \YuriyMartini\Laravel\Authorization\Policy
{
protected static function getModel(): string
{
return \App\Models\User::class;
}
}