openclassify/app/Models/User.php
copilot-swe-agent[bot] 64930897c3 feat: Install FilamentPHP v5, add Admin/Partner modules, Docker support
- Fix CI workflow: actions/checkout@v6 → v4
- Install FilamentPHP ^5.0 and spatie/laravel-permission ^7.2
- Remove laravel/breeze from require-dev (replaced by Filament auth)
- Update User model: implements FilamentUser, HasTenants, HasRoles
- Publish Spatie permission migrations for role-based access
- Create Admin module with FilamentPHP panel at /admin
  - UserResource, CategoryResource, ListingResource, LocationResource
  - Role-based access (admin role required)
- Create Partner module with tenant-isolated panel at /partner/{id}
  - ListingResource scoped to authenticated user
- Update modules_statuses.json: add Admin and Partner modules
- Update DatabaseSeeder: create admin/partner users with roles
- Improve seeders: LocationSeeder (10 countries), CategorySeeder (8 categories with children), ListingSeeder (10 sample listings)
- Add Docker support: Dockerfile, docker-compose.yml, docker-compose.dev.yml
- Add GitHub Codespaces: .devcontainer/devcontainer.json
- Update .env.example with Filament-relevant settings
- Update README.md with full documentation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-03 08:07:28 +00:00

53 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasTenants;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Collection;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements FilamentUser, HasTenants
{
use HasFactory, HasRoles, Notifiable;
protected $fillable = ['name', 'email', 'password'];
protected $hidden = ['password', 'remember_token'];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function canAccessPanel(Panel $panel): bool
{
return match ($panel->getId()) {
'admin' => $this->hasRole('admin'),
'partner' => true,
default => false,
};
}
public function getTenants(Panel $panel): Collection
{
return collect([$this]);
}
public function canAccessTenant(Model $tenant): bool
{
return $tenant->getKey() === $this->getKey();
}
public function listings()
{
return $this->hasMany(\Modules\Listing\Models\Listing::class);
}
}