Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function register(Request $request)
'email' => $request->email,
'cellphone' => $request->cellphone,
'password' => bcrypt($request->password),
'is_admin' => $request->is_admin ?? false,
'is_admin' => $isAdmin,
'bearer_apibrasil' => $request->bearer_apibrasil ?? null,
'balance' => 0 //sempre comeca com 0
]);
Expand Down
15 changes: 4 additions & 11 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,17 @@ protected function casts(): array
}


//TESTE
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
if (empty($model->id)) {
$model->id = (string) Str::uuid();
static::creating(function ($user) {
if (empty($user->id)) {
$user->id = (string) Str::uuid();
}
});

parent::boot();

static::creating(function ($user) {
if (User::count() === 0) {
if (self::count() === 0) {
$user->is_admin = true; // Primeiro usuário
} else {
$user->is_admin = false; // Todos os outros
}
});
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->uuid();
$table->uuidMorphs('tokenable_id');
$table->uuid('id')->primary();
$table->uuidMorphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
Expand Down
9 changes: 1 addition & 8 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

namespace Database\Seeders;

use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class DatabaseSeeder extends Seeder
{
Expand All @@ -23,9 +18,7 @@ public function run(): void
// 'email' => 'test@example.com',
// ]);

$this->call([
UserSeeder::class
]);
// Add seeder calls here when needed

}
}
28 changes: 0 additions & 28 deletions database/seeders/UserSeeder.php

This file was deleted.