// 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;
}
}
// 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;
}
}