F
Filament14mo ago
Askancy

Using custom function in a form

I have a page where I have a form textarea, in the textarea I have all the ids divided by comma example: qIcTM8WXFjk,8X2kIfS6fb8 These ids are processed through a function of mine:
function processMultipleVideos($request)
{
$all_id = explode(',', $request->id_video);

foreach ($all_id as $value) {
$all_idcode = Youtube::getVideoInfo($value);
$all_id_de = json_encode($all_idcode);
$video = new Video();
$video->id_video = $all_idcode->id;
$video->name= $all_idcode->snippet->title;
$video->save();
}
}
function processMultipleVideos($request)
{
$all_id = explode(',', $request->id_video);

foreach ($all_id as $value) {
$all_idcode = Youtube::getVideoInfo($value);
$all_id_de = json_encode($all_idcode);
$video = new Video();
$video->id_video = $all_idcode->id;
$video->name= $all_idcode->snippet->title;
$video->save();
}
}
How can I tell Filamentphp to use this function to post data? Also, how do I add a button next to "New Video" in the header? In the documentation I find only references to how to add buttons in tables
6 Replies
bwurtz999
bwurtz99914mo ago
When you say you have a page, is this a custom page? Or a standard Filament create page?
Askancy
AskancyOP14mo ago
Standard created by filament any idea?
Askancy
AskancyOP14mo ago
In my case, should I create the beforeCreate() function in VideoResource? And how do I get the $request of the created form?
LeandroFerreira
LeandroFerreira14mo ago
you can use beforeCreate, afterCreate... you can get the data using $this->data after create you can use $this->record or getRecord()
Want results from more Discord servers?
Add your server