DGINX
DGINX
FFilament
Created by DGINX on 1/25/2024 in #❓┊help
Skip Import when model is existing
Ok i find it by myself out. Easily return null in resolveRecord() Function
public function resolveRecord(): ?User
{
if ($this->options['existingAction'] === "skip") {
if(User::whereName($this->data['name'])->first())
return null;
}

return new User();
}
public function resolveRecord(): ?User
{
if ($this->options['existingAction'] === "skip") {
if(User::whereName($this->data['name'])->first())
return null;
}

return new User();
}
2 replies
FFilament
Created by DGINX on 1/24/2024 in #❓┊help
auth()->user() everytime null
AdminAuthenticatedMiddleware.php
public function handle(Request $request, Closure $next, $guard = null)
{
Auth::setDefaultDriver('admin');
if (!Auth::check()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect(route('filament.admin.auth.login', ['return_url' => $request->url()]));
}
}
return $next($request);

}
public function handle(Request $request, Closure $next, $guard = null)
{
Auth::setDefaultDriver('admin');
if (!Auth::check()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect(route('filament.admin.auth.login', ['return_url' => $request->url()]));
}
}
return $next($request);

}
3 replies
FFilament
Created by DGINX on 1/24/2024 in #❓┊help
auth()->user() everytime null
AdminPanelProvider.php
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->font('JetBrains Mono', provider: BunnyFontProvider::class)
->login()
->colors([
'primary' => Color::Amber,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
//Widgets\FilamentInfoWidget::class,
])
->plugins([
FilamentSpatieLaravelHealthPlugin::make()
->usingPage(HealthCheckResults::class),
FilamentSpatieLaravelBackupPlugin::make()
->usingPage(BackupsResults::class)
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
AdminMiddleware::class,

DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authGuard('admin')
->authMiddleware([
AdminAuthenticatedMiddleware::class,
]);
}
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->font('JetBrains Mono', provider: BunnyFontProvider::class)
->login()
->colors([
'primary' => Color::Amber,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
//Widgets\FilamentInfoWidget::class,
])
->plugins([
FilamentSpatieLaravelHealthPlugin::make()
->usingPage(HealthCheckResults::class),
FilamentSpatieLaravelBackupPlugin::make()
->usingPage(BackupsResults::class)
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
AdminMiddleware::class,

DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authGuard('admin')
->authMiddleware([
AdminAuthenticatedMiddleware::class,
]);
}
AdminMiddleware.php
public function handle(Request $request, Closure $next)
{
Auth::setDefaultDriver('admin');

return $next($request);

}
public function handle(Request $request, Closure $next)
{
Auth::setDefaultDriver('admin');

return $next($request);

}
3 replies