There is a model called Book, a book can have many chapters ( one-to-many relationship ) each chapter has many sections ( one-to-many relationship ).
class Book extends Model
{
public function sections()
{
return $this->hasMany('App\Section');
}
}
class Section extends Model
{
public function chapters()
{
return $this->hasMany('App\Chapter');
}
}
And lets say I have this Scenario:
1 - user "A" has created a book ( title, desc, sections).
2 - user "A" asked for an approval from admin. then admin approve user "A" 's book.
3 - user "A" decided to delete a book's section, edit a section's chapter or maybe edit the book's title.
4 - then user "A" asked for a an approval from admin for these changes.
and then the admin can approve or disapprove these changes:
1 - if admin approve , apply the new changes.
2 - if admin disapprove , don't apply new changes. keep old data ( with its old relations data ( sections and chapters ).
How to accomplish something like this? is this possible?