F
Filamentβ€’16mo ago
Bruno Pereira

Missing files running php artisan vendor:publish --tag="filament-views" on filament v3

Hello there, I just started a new laravel project and installed filament v3 according the documentation and I want to override the login view so that it only has a button to login via Socialite. After running the command php artisan vendor:publish --tag="filament-views" It generates a bunch of folders and blade files but no views like login.blade.php for example... filament v3.0-stable Laravel v10.17.1 Is it a bug? Many thanks
No description
34 Replies
notakebaks
notakebaksβ€’15mo ago
Hi @coolmanpt , were you ever able to find a solution for this? I'm trying to do the same thing.
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
Hey! nope I didn't I just stayed in V2.
notakebaks
notakebaksβ€’15mo ago
😭 @Filament I'm guessing it's by design, but in V3 we are no longer able to publish the login page views so we can edit. Is there an "official" way to add things like Socialite links as a login method?
awcodes
awcodesβ€’15mo ago
you can still copy the views out of vendor folder πŸ™‚ but for auth pages you shouldn't need to. you can create your own view and Login Class and pass it to the ->login() method on your panel you could even extend Filament's Login Class
notakebaks
notakebaksβ€’15mo ago
Ah.. I've seen some mention of that when researching so I'll continue down that path. Thanks for the quick response! @coolmanpt - Once I get this working I'll let you know what I did.. maybe that would bring V3 back into play for you.
awcodes
awcodesβ€’15mo ago
For example, not your full use case, but I do this for local dev so I don't have to fill the form every time:
use Filament\Pages\Auth\Login as BasePage;

class Login extends BasePage
{
public function mount(): void
{
parent::mount();

$this->form->fill([
'email' => '[email protected]',
'password' => 'password',
'remember' => true,
]);
}
}
use Filament\Pages\Auth\Login as BasePage;

class Login extends BasePage
{
public function mount(): void
{
parent::mount();

$this->form->fill([
'email' => '[email protected]',
'password' => 'password',
'remember' => true,
]);
}
}
So doing something similar you can also tell it to render a different view
protected static string $view = 'my-custom-login-view';
protected static string $view = 'my-custom-login-view';
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
Oh, I see I thought the login() was only to enable login in the panel. Gotta check it out
awcodes
awcodesβ€’15mo ago
or you can do you're own Login class without extending Filament's, just depends on what level of functionality you need it to handle. Technically, yes, but it expects an override. The other auth routes all work the same way too, ->register(), ->verifyEmail(), etc
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
Gotcha, my goal with is is to make a boilerplate for my company internal projects, since we use Azure as our email system and such we just need the Socialite provider to work But I'll check that soon and report here
awcodes
awcodesβ€’15mo ago
Should be doable just to make the example complete. πŸ™‚
$panel->login(Path\To\Custom\Login::class)
$panel->login(Path\To\Custom\Login::class)
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
and it can be a simple page created by the filament create page command and just extend it?
awcodes
awcodesβ€’15mo ago
i don't think there's a command for that. the auth pages use the simple layout, since the other pages require a logged in user
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
php artisan make:filament-page Settings I mean this one Replace Settings with CustomLogin for example
awcodes
awcodesβ€’15mo ago
yea, pretty sure those commands only generate 'panel' pages no, the login class is not a page it is a livewire component that is on the page here's what the login blade view looks like
<x-filament-panels::page.simple>
@if (filament()->hasRegistration())
<x-slot name="subheading">
{{ __('filament-panels::pages/auth/login.actions.register.before') }}

{{ $this->registerAction }}
</x-slot>
@endif

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::auth.login.form.before') }}

<x-filament-panels::form wire:submit="authenticate">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::auth.login.form.after') }}
</x-filament-panels::page.simple>
<x-filament-panels::page.simple>
@if (filament()->hasRegistration())
<x-slot name="subheading">
{{ __('filament-panels::pages/auth/login.actions.register.before') }}

{{ $this->registerAction }}
</x-slot>
@endif

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::auth.login.form.before') }}

<x-filament-panels::form wire:submit="authenticate">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::auth.login.form.after') }}
</x-filament-panels::page.simple>
if you look in the vendor/filament/filament/resources/views/pages/auth you'll see all the views. you can copy them to your app and do what you need to do with them
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
Yeah I'm checking the repo now and found it. So I need to create a livewire component, extend it and call it on the login method
awcodes
awcodesβ€’15mo ago
1. Create CustomLogin class and either extend Login or don't 2. Set the $view property in CustomLogin to reference your blade file 3. Copy over this code into your blade file 4. Add additional functionality to the class and the view per your needs 5. Add ->login(CustomLogin::class)
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
🫑 I'll try it, and if it works I'll leave a message here and mark it as the solution so that the issue closes
awcodes
awcodesβ€’15mo ago
by using this component <x-filament-panels::page.simple> you are extending the livewire component. so no need to actually make one, unless you are using your own whole page template.
notakebaks
notakebaksβ€’15mo ago
In terms of just pointing to a different view, it worked like a charm.. Going to post what I did for the quick mockup.. What are the tags again for code snippets? ☺️
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
3 -> `
awcodes
awcodesβ€’15mo ago
3 back ticks and the language to highlight it
notakebaks
notakebaksβ€’15mo ago
First, I created a simple PHP class and had it extend the Filament login class. Then I overrode the view string:
<?php

namespace App\Filament\Pages\Auth;

use Filament\Pages\Auth\Login as AuthLogin;

class Login extends AuthLogin {

/**
* @var view-string
*/
protected static string $view = 'login';

}
<?php

namespace App\Filament\Pages\Auth;

use Filament\Pages\Auth\Login as AuthLogin;

class Login extends AuthLogin {

/**
* @var view-string
*/
protected static string $view = 'login';

}
Then in the AdminPanelProvider, I just passed that new custom Login class to the method
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login(Login::class)
... etc
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login(Login::class)
... etc
Of course, in this case I would copy the Filament login view, since I want all of it just with the addition of a button for Google (or whichever OAuth provider)
awcodes
awcodesβ€’15mo ago
depending on where you want those buttons could just render them into one of the renderhooks on that page and not have to override the entire view. πŸ™‚
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
I think it nails it I guess
notakebaks
notakebaksβ€’15mo ago
Even better Thanks for the help! I really appreciate it
awcodes
awcodesβ€’15mo ago
i'm sure the render hooks render outside the box on the page though. that's why i bring it up
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
I guess we solved this. Many thanks πŸ™‚
awcodes
awcodesβ€’15mo ago
You're not getting out of v3 that easy. It's too good not to use it. πŸ˜‰
notakebaks
notakebaksβ€’15mo ago
Early adopter till I die!
awcodes
awcodesβ€’15mo ago
Cheers and good luck on the projects
notakebaks
notakebaksβ€’15mo ago
Thanks again
Bruno Pereira
Bruno PereiraOPβ€’15mo ago
Thanks and likewise πŸ‘πŸ»
cheesegrits
cheesegritsβ€’15mo ago
Remember to delete those views you published.
notakebaks
notakebaksβ€’15mo ago
And just to close the loop, I tried using the render hook as well by simply chaining it to my panel in the AdminPanelProvider:
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->renderHook(
'panels::auth.login.form.after',
fn (): View => view('login'),
)
...
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->renderHook(
'panels::auth.login.form.after',
fn (): View => view('login'),
)
...
Want results from more Discord servers?
Add your server