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

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -