Admin Model instead of User model

Hi everyone, I’ve just migrated my project from Filament v2 to v3 and I’m encountering an issue with authentication. Previously, I was using the FilamentUser trait on my custom Admin model, and everything worked fine. However, after the upgrade, it seems Filament is now defaulting to the User model for login. In my application, I have separate tables for users and admins, and I need Filament to authenticate using the Admin model instead of User. What’s the recommended approach to achieve this in Filament v3? Thanks in advance!
Solution:
The purge was the problem. Thank you for your time.
Jump to solution
17 Replies
toeknee
toeknee5mo ago
Medium
Change Laravel Authentication Model for FilamentPHP 3
I was developing an e-commerce platform where I wanted to separate the customers from the website administrators for various reasons.
RoxanaAnghel
RoxanaAnghelOP5mo ago
I've added ->authGuard('admin') in the AdminPanelProvider.php. I have the admin guard in auth.php
Dennis Koch
Dennis Koch5mo ago
That's not working? Did you try clearing the config? Any customisation to the Login class?
RoxanaAnghel
RoxanaAnghelOP5mo ago
It is working now with this line, the only problem I have now is that my styles are not working on the server, and on local are working only if I run yarn dev.
toeknee
toeknee5mo ago
are you running npm run build on prod?
RoxanaAnghel
RoxanaAnghelOP5mo ago
i am running it in my yml before the deployment.
toeknee
toeknee5mo ago
your yml? Usually the assets built at not committed in git. So deploying without running the build would mean missing assets
RoxanaAnghel
RoxanaAnghelOP5mo ago
this is a part from my yml:
- name: Yarn Build
id: Yarn-Build
if: success()
run: |
yarn build

- name: Deploy
id: Deploy
uses: up9cloud/action-rsync@v1.1
if: success()
env:
HOST: project name
USER: user
KEY: ${{secrets.DEPLOY_SSH_KEY}}
SSH_ARGS: ' -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

VERBOSE: true
ARGS: -carEzhvP --delete-before --include '.env' --exclude '.[!.]*' --exclude 'node_modules' --exclude 'cache' --exclude 'documentation' --exclude 'docker-compose.yml' --exclude 'Makefile' --exclude '*.log' --exclude 'jsconfig.json' --exclude '*.xml' --exclude 'storage/framework' --exclude 'storage/logs' --exclude 'bootstrap/cache' --exclude 'app/public' --exclude 'public/assets-email'

SOURCE: ./
TARGET: ~/project name/

PRE_SCRIPT: |
echo "Start at: " $(date -u)

POST_SCRIPT: |
cd project name; cd scripts; chmod 744 redis_key_cleanup.sh
mkdir -p ~/project name/bootstrap/cache || true
mkdir -p ~/project name/storage/framework || true
mkdir -p ~/project name/storage/framework/cache || true
mkdir -p ~/project name/storage/framework/sessions || true
mkdir -p ~/project name/storage/framework/testing || true
mkdir -p ~/project name/storage/framework/views || true
php ~/project name/artisan storage:link
php ~/project name/artisan migrate --force
php ~/project name/artisan optimize:clear
php ~/project name/artisan route:cache
php ~/project name/artisan view:cache

echo "Stop at: " $(date -u)
- name: Yarn Build
id: Yarn-Build
if: success()
run: |
yarn build

- name: Deploy
id: Deploy
uses: up9cloud/action-rsync@v1.1
if: success()
env:
HOST: project name
USER: user
KEY: ${{secrets.DEPLOY_SSH_KEY}}
SSH_ARGS: ' -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

VERBOSE: true
ARGS: -carEzhvP --delete-before --include '.env' --exclude '.[!.]*' --exclude 'node_modules' --exclude 'cache' --exclude 'documentation' --exclude 'docker-compose.yml' --exclude 'Makefile' --exclude '*.log' --exclude 'jsconfig.json' --exclude '*.xml' --exclude 'storage/framework' --exclude 'storage/logs' --exclude 'bootstrap/cache' --exclude 'app/public' --exclude 'public/assets-email'

SOURCE: ./
TARGET: ~/project name/

PRE_SCRIPT: |
echo "Start at: " $(date -u)

POST_SCRIPT: |
cd project name; cd scripts; chmod 744 redis_key_cleanup.sh
mkdir -p ~/project name/bootstrap/cache || true
mkdir -p ~/project name/storage/framework || true
mkdir -p ~/project name/storage/framework/cache || true
mkdir -p ~/project name/storage/framework/sessions || true
mkdir -p ~/project name/storage/framework/testing || true
mkdir -p ~/project name/storage/framework/views || true
php ~/project name/artisan storage:link
php ~/project name/artisan migrate --force
php ~/project name/artisan optimize:clear
php ~/project name/artisan route:cache
php ~/project name/artisan view:cache

echo "Stop at: " $(date -u)
i have the assets in public/build
toeknee
toeknee5mo ago
If you inspect the browser is it trying to load the assets?
RoxanaAnghel
RoxanaAnghelOP5mo ago
No description
toeknee
toeknee5mo ago
Seems ok to me what type of styles are not loading?
RoxanaAnghel
RoxanaAnghelOP5mo ago
No description
No description
toeknee
toeknee5mo ago
Yeah not sure what's going on that, compare the theme size to your theme size?
RoxanaAnghel
RoxanaAnghelOP5mo ago
this is my local when i am running yarn dev and everything is working fine
No description
toeknee
toeknee5mo ago
notice your theme is 132kb.... opposed to prod is 13.... So it's not finding the vendor folders or the paths I suspect? Run it manually on the server and see what it says.
RoxanaAnghel
RoxanaAnghelOP5mo ago
Unfortunately I cannot run build on the server
Solution
RoxanaAnghel
RoxanaAnghel5mo ago
The purge was the problem. Thank you for your time.

Did you find this page helpful?