commit 12.01

This commit is contained in:
Владимир
2026-01-12 14:25:15 +00:00
parent 36084ba590
commit ae5ab2554b
26 changed files with 1116 additions and 1083 deletions

View File

@@ -2,44 +2,24 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable // все пользователи системы
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens, Notifiable;
protected $fillable = [
'name',
'email',
'password',
'role',
'role',
'phone'
];
protected $hidden = [
'password',
'remember_token',
];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
// Проверяет админ или сотрудник
public function isEmployeeOrAdmin()
{
return $this->role == 'employee' || $this->role == 'admin';
}
// Для запросов - все сотрудники и админы
public static function scopeEmployeeOrAdmin($query)
{
return $query->whereIn('role', ['employee', 'admin']);
}
}
}