Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: while using OnEachRow it not rollback entries from second table if database or some another error occur. or you can say it delete entries from parent table but not child table. i am trying to do relation entries #3837

Closed
1 task done
krishantalwar opened this issue Dec 20, 2022 · 1 comment

Comments

@krishantalwar
Copy link

krishantalwar commented Dec 20, 2022

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1

What version of Laravel are you using?

8.75

What version of PHP are you using?

8.1.6

Describe your issue

if their error comes it rollback the entries from the first table. but it does not roll back the entries from the second table.

Can anyone guide how it is possible?

what my case is.

if their error comes it rollback the entries from the agent table. but it does not roll back the entries from the payment table.

How can the issue be reproduced?

To create this error I hardcoded the value for the third row and set the status value to null. but status only takes an integer value why it creates the error.

it gives an error Incorrect integer value: '' for column 'status'

but it rollbacks entries from the agent table but not from the payment table

class noteImport implements OnEachRow {

    public function onRow(Row $row){
        $row = $row->toArray();
        
            $Option = [
            "firstpay" => 1,
            "amount" => 1,
            "payment_type" => 1,
            "info" => "1",
            "enter_date" => date('y/m/d'),
            "recieve_date" => date('y/m/d'),
            "status" => $row['srno'] != 3 ? 1 : "",     
            ];

            $agent = Agent::create([
            "agent_code" => "1",
            "name" => "1",
            "address" => "1",
            "phone" => 454,
            "password" => "asd",
            "upload" => "1",
            "status" => 1,
            ]);

        $agent->payment()->create($Option);
    }
}

What should be the expected behaviour?

The expected behavior is it should delete an entry from the second (payment) table

@krishantalwar krishantalwar changed the title [Bug]: while using OnEachRow it not rollback entries from second table if database or some another error occur [Bug]: while using OnEachRow it not rollback entries from second table if database or some another error occur. or you can say it delete entries from parent table but not child table Dec 20, 2022
@krishantalwar krishantalwar changed the title [Bug]: while using OnEachRow it not rollback entries from second table if database or some another error occur. or you can say it delete entries from parent table but not child table [Bug]: while using OnEachRow it not rollback entries from second table if database or some another error occur. or you can say it delete entries from parent table but not child table. i am trying to do relation entries Dec 20, 2022
@stale stale bot added the stale label Feb 18, 2023
@stale
Copy link

stale bot commented Feb 19, 2023

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.

@stale stale bot closed this as completed Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant