access request input

hello, I hope everyone is doing well. how can I access request input, I tried the Laravel way using request('key') but returns null, tried to dd(request()=>all()) it returns some livewire component json data, is there any other way ? am I missing something ? Thanks in advance guys.
Solution:
If you are using Filament hooks, you can access the data via $this->data
Jump to solution
14 Replies
christmex
christmex4mo ago
request imput? form a form? show us some code 😊
Hajres#0001
Hajres#00014mo ago
yes, form input, trying to access like request('key') returns null.
Hajres#0001
Hajres#00014mo ago
No description
christmex
christmex4mo ago
u using action? or what? just pass the param so like function(array $data) the u can access the data
christmex
christmex4mo ago
actually this is not what im looking for, but here's some reference for access the submitted form u can see it here for using resource https://filamentphp.com/docs/3.x/panels/resources/creating-records and here for action https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create
Hajres#0001
Hajres#00014mo ago
actually, im trying to access from a model observer's create method.
LeandroFerreira
LeandroFerreira4mo ago
Could you explain what are you trying to do?
christmex
christmex4mo ago
hmm, what about this https://laravel.com/docs/11.x/eloquent#observers or let's say u create inside model boot
protected static function booted(): void {
static::creating(function (YourModel $data): void {
dd($data);
});
}
protected static function booted(): void {
static::creating(function (YourModel $data): void {
dd($data);
});
}
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Hajres#0001
Hajres#00014mo ago
i'm trying to access data from a submitted form to do some calculations, using the results to decide whether to autorize the user to create the model in the observer.
LeandroFerreira
LeandroFerreira4mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Solution
LeandroFerreira
LeandroFerreira4mo ago
If you are using Filament hooks, you can access the data via $this->data
Hajres#0001
Hajres#00014mo ago
sorry, i meant policy not observer trying to acess from policy
Hajres#0001
Hajres#00014mo ago
i think i will just go with using filament hooks, thanks. @Leandro Ferreira @christmex