php - $model->get() returns soft deletes -


when run following method, returns collection soft deletes included...and obviously, shouldn't.

return $twitter_oauth->get(); 

i think might boot function in twitteroauth model. use boot meth below soft delete relevant models (works should).

public static function boot() {     twitteroauth::deleting(function($twitter_oauth) {         $twitter_oauth->posts()->delete();     });      twitteroauth::restoring(function($twitter_oauth) {         $twitter_oauth->posts()->withtrashed()->restore();     }); } 

now if i remove boot method , run same get query, soft deletes not appear in collection. weird. have experience or run issue - or see problem?

i know use wherenull in queries, seems hack. there must better way...

needed include parent::boot(); in boot method. solved it.

public static function boot() {     parent::boot();      twitteroauth::deleting(function($twitter_oauth) {         $twitter_oauth->posts()->delete();     });      twitteroauth::restoring(function($twitter_oauth) {         $twitter_oauth->posts()->withtrashed()->restore();     }); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -