How to integrate filament v3 with stored procedure

I want to use stored procedures for CRUD needs. But I'm confused about how to call the stored procedure function from the create/edit button, or when I want to display the resulting data from the stored procedure in a table. anyone can help ?
Solution
I think I'm going to record a video about this concept. Do you mind if I include your question in the video?(including your discord user name).
Here's an example of using stored procedures to manage the users in a filament resource. First the create action
// app/Filament/Resources/Pages/CreateUser.php
class CreateUser extends CreateRecord
{
    protected static string $resource = UserResource::class;

    protected function handleRecordCreation(array $data): Model
    {
        // Execute the stored procedure with the form data. The @last_id is expected to hold
        // the last inserted ID from the database
        DB::statement('CALL sp_insert_user(?, ?, ?, @last_id)', [$data['name'], $data['email'], $data['password']]);

        // Grab the last inserted ID
        $last_id = DB::scalar('SELECT @last_id');
        
        // Load the newly created record from the database        
        $user = User::find($last_id);

        return $user;
    }
}
Was this page helpful?