I have an application in Laravel 5.1 where the following tables are setup;
- timesheet
- row
- day_total
- segment_totals
Rows belong to timesheets. Day totals belong to timesheets. Segment totals belong to rows.
When a timesheet is deleted, I also want it to delete the rows from row, day_total and segment_total as well as the row from timesheet table itself.
I hav setup the following boot method in my timesheet model;
/**
* Boot the model.
*
*/
public static function boot()
{
parent::boot();
static::deleting(function($timesheet)
{
$timesheet->row()->delete();
$timesheet->dayTotal()->delete();
});
}
I have setup the following in the row model;
/**
* Boot the model.
*
*/
public static function boot()
{
parent::boot();
static::deleting(function($row)
{
$row->day()->delete();
$row->segmentTotal()->delete();
});
}
When the timesheet is deleted, the row and dayTotal rows are deleted, but the day and segmentTotals do not get deleted. How can I make Laravel fire the delete on the row model?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire