1. Go to this page and download the library: Download zofe/auth-module 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/ */
zofe / auth-module example snippets
use App\Modules\Auth\Traits\Impersonate;
class User extends Model
{
use Impersonate;
use App\Modules\Auth\Traits\Authorize;
class CompaniesEdit extends Component
{
use Authorize;
public function booted()
{
$this->authorize('admin|edit users');
}
namespace App\Modules\Companies\Livewire;
use App\Models\Company;
use App\Modules\Auth\Traits\Limit;
use Livewire\Component;
class CustomersTable extends Component
{
use Limit;
public function booted()
{
$this->limit();
}
namespace App\Modules\Companies\Limits;
use App\Models\Company;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
class CompanyLimit
{
public static function limit($except = [])
{
$user = auth()->user();
Company::addGlobalScope('onlyMine', function (Builder $builder) use (auth()->user()) {
$builder->where('parent_id', $user->company_id)
->orWhere('id', $user->company_id)
});
}
}