Transactions mysql laravel

I have created a store method which stores two step-form that saves data to different tables. I want a scenario were if a commit fails for any of the tables it should rollback.


public function store()

        $staffrecs = Staffrecord::create([
            'staff_id' => '',
            'first_name' => $this->state['first_name'],
            'middle_name' => $this->state['middle_name'],
            'last_name' => $this->state['last_name'],
            'designation' => $this->state['designation'],
            'grade_level_id' => $this->state['grade_level_id'],
            'phone_number' => $this->state['phone_number'],
            'email' => $this->state['email'],
            'address' => $this->state['address'],

            'account_number' => $this->state['account_number'],
            'account_name' => $this->state['account_name'],
            'bank_name' => $this->state['bank_name'],
            'sort_code' => $this->state['sort_code'],

        return redirect()->route('dashboard');
}catch (\Exception $e)
        return false;

So use a transaction?

As I read through the internet I have seen your signature everywhere… I love what you do and thanks for the material