PHP code example of alikazemayni / easy_permission
1. Go to this page and download the library: Download alikazemayni/easy_permission 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/ */
alikazemayni / easy_permission example snippets
public function permissions(): BelongsToMany
{
$this->belongsToMany(Permission::class, 'user_permission',
'user_id', 'permissions_id')->withTimestamps();
}
public function user(Request $request): JsonResponse{
$permissions = User::findOrFail($request->user_id)->permissions();
$permissions->sync($request->permissions);
}