Jamie Cee
Jamie Cee
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
👋
6 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
protected function getFormSchema(): array
{
return [
Hidden::make('state')->default($this->state),
Hidden::make('client_id')->default($this->clientId),
Hidden::make('auth_token')->default($this->authToken),
];
}

protected function getActions(): array
{
return [
Action::make('approve')
->label('Authorize')
->color('success')
->action('approve')
->icon('heroicon-o-check'),

Action::make('deny')
->label('Cancel')
->color('danger')
->action('deny')
->icon('heroicon-o-x'),
];
}

public function getViewData(): array
{
return [
'clientName' => $this->clientName,
'scopes' => $this->scopes,
'state' => $this->state,
'clientId' => $this->clientId,
'authToken' => $this->authToken,
];
}
}
protected function getFormSchema(): array
{
return [
Hidden::make('state')->default($this->state),
Hidden::make('client_id')->default($this->clientId),
Hidden::make('auth_token')->default($this->authToken),
];
}

protected function getActions(): array
{
return [
Action::make('approve')
->label('Authorize')
->color('success')
->action('approve')
->icon('heroicon-o-check'),

Action::make('deny')
->label('Cancel')
->color('danger')
->action('deny')
->icon('heroicon-o-x'),
];
}

public function getViewData(): array
{
return [
'clientName' => $this->clientName,
'scopes' => $this->scopes,
'state' => $this->state,
'clientId' => $this->clientId,
'authToken' => $this->authToken,
];
}
}
6 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
My page
class OAuthAuthorizationPage extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-key';
protected static string $view = 'filament.pages.passport-authorize';

public ?string $clientName = null;
public ?array $scopes = [];
public ?string $state = null;
public ?string $clientId = null;
public ?string $authToken = null;

public function mount(Request $request)
{
$this->clientName = $request->client->name ?? 'Unknown App';
$this->scopes = $request->scopes ?? [];
$this->state = $request->state;
$this->clientId = $request->client->getKey();
$this->authToken = $request->authToken;
}

public function approve()
{
$response = redirect()->route('passport.authorizations.approve', [
'state' => $this->state,
'client_id' => $this->clientId,
'auth_token' => $this->authToken,
]);

Notification::make()->title('Access Granted')->success()->send();
return $response;
}

public function deny()
{
$response = redirect()->route('passport.authorizations.deny', [
'state' => $this->state,
'client_id' => $this->clientId,
'auth_token' => $this->authToken,
]);

Notification::make()->title('Access Denied')->warning()->send();
return $response;
}
class OAuthAuthorizationPage extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-key';
protected static string $view = 'filament.pages.passport-authorize';

public ?string $clientName = null;
public ?array $scopes = [];
public ?string $state = null;
public ?string $clientId = null;
public ?string $authToken = null;

public function mount(Request $request)
{
$this->clientName = $request->client->name ?? 'Unknown App';
$this->scopes = $request->scopes ?? [];
$this->state = $request->state;
$this->clientId = $request->client->getKey();
$this->authToken = $request->authToken;
}

public function approve()
{
$response = redirect()->route('passport.authorizations.approve', [
'state' => $this->state,
'client_id' => $this->clientId,
'auth_token' => $this->authToken,
]);

Notification::make()->title('Access Granted')->success()->send();
return $response;
}

public function deny()
{
$response = redirect()->route('passport.authorizations.deny', [
'state' => $this->state,
'client_id' => $this->clientId,
'auth_token' => $this->authToken,
]);

Notification::make()->title('Access Denied')->warning()->send();
return $response;
}
6 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
If I try this approach
public function toResponse($request)
{
// return (new OAuthAuthorizationPage($this->parameters))->render();
// Merge the parameters into the request, so they're available in mount()
$request->merge($this->parameters);

// Instantiate the page using Filament's make() method, which ensures lifecycle methods like mount() are called
$page = new OAuthAuthorizationPage();

$page->mount($request);

// Render the page
return $page->render();
}
public function toResponse($request)
{
// return (new OAuthAuthorizationPage($this->parameters))->render();
// Merge the parameters into the request, so they're available in mount()
$request->merge($this->parameters);

// Instantiate the page using Filament's make() method, which ensures lifecycle methods like mount() are called
$page = new OAuthAuthorizationPage();

$page->mount($request);

// Render the page
return $page->render();
}
I get Using $this when not in object context
6 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
Thank you
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
Yeah, so the combination of the relationship, and changing the morphs model to be a uuid, looks like its working.
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
Not using saveRelationships as of yet, will give that a go
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
So you just want to save the file?
At present, yes. When I use the SpatieMediaLibraryFileUpload component (from spatie docs), my data from form->getState or getRawState is null, but if I use Filaments default FIleUpload, it returns string as normal etc. Im still trring to associate that file with the Spatie media mainly for file information etc, but just cant obtain the 'document'
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
The main use is default, it's just trying to put it on a custom page, rather than a resource. So I've setup the form as normal, and im trying to use the spatie media library (https://filamentphp.com/plugins/filament-spatie-media-library#form-component). But the basic usage set out in the docs doesn't appear to be working. Not adding anything extra currently
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
So does using getRawState() not handle the actual uploading part? Assuming Id then have to do that overriding to manage how and where data is uploaded?
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
No description
15 replies
FFilament
Created by Jamie Cee on 2/10/2025 in #❓┊help
File Upload within a custom page is null
So, if I use FileUpload::make(), it appears to work, but the Spatie one doesnt... but the documentation says the Spatie one is used the same way as the FileUpload component?
15 replies
FFilament
Created by Risebille on 1/23/2025 in #❓┊help
File Upload Form In Server
do you have a livewire.php config, is there any validation in there that might be restricting it? If not, Im a bit last im afraid
11 replies
FFilament
Created by Jamie Cee on 1/22/2025 in #❓┊help
Code to run after Related Page update
Ah finally found it. 'using' function in the edit action right before it opens the form.
6 replies
FFilament
Created by Risebille on 1/23/2025 in #❓┊help
File Upload Form In Server
Anything in developer tools when you press the upload button itself?
11 replies
FFilament
Created by Risebille on 1/23/2025 in #❓┊help
File Upload Form In Server
Have you ran artisan storage:link, given the storage file permissions, have enough space to upload i.e. upload_max_filesize etc. I once had an issue requiring imagemagick, not sure if that may be needed?
11 replies
FFilament
Created by Risebille on 1/23/2025 in #❓┊help
File Upload Form In Server
What are you using for your server?
11 replies
FFilament
Created by David Chong 1228 on 1/23/2025 in #❓┊help
Is Filament able to work out add new tab like chrome
What are you meaning by detect tabs? Just referring to a page title?
8 replies
FFilament
Created by Risebille on 1/23/2025 in #❓┊help
File Upload Form In Server
Are you definitely uploading an image?
11 replies
FFilament
Created by Jamie Cee on 1/22/2025 in #❓┊help
Code to run after Related Page update
Anyone have any ideas?
6 replies