-
composer.json
Open in GitHub{ "require": { "php": "^7.4|^8.0", // "spatie/laravel-permission": "^3.18" }, }
-
app/Models/User.php
Open in GitHubuse Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable implements MustVerifyEmail { use HasRoles; }
-
app/Http/Controllers/RegisterController.php
Open in GitHubclass RegisterController extends Controller { public function register(Request $request) { // $role = Role::where("name","=","free")->first(); if($role == null) { $role = Role::create(['name' => 'free']); } $user->assignRole([$role->id]); // } }