need some help please
when i delete a campaign form my crowdfunding platform i got a error if this campaign have already some payments ,
the payments still in the database without campaign so i got the error in my payments list view . my only solution is to go to database and delete payments that is belong to the deleted campaign.
when i delete campaign , it must also delete his own payments
- campaign Controller (delete function) :
public function deleteCampaigns($id = 0){
if(config('app.is_demo')){
return redirect()->back()->with('error', __('app.feature_disable_demo'));
}
if ($id){
$campaign = Campaign::find($id);
if ($campaign){
$campaign->delete();
}
}
return back()->with('success', trans('app.campaign_deleted'));
}
every payments in database is related to a campaign_id from campaign table