mysql - error not reported when taking input of deleted resource(soft deletion) in laravel 5 php -


i have model "topics".

say, have soft deleted resource id=1 in topics.

i have model "posts" has attribute "topics_id".

now,i tried insert resource in posts table "topic_id"=1,it getting inserted table.but, want report exception or error.i know can implemented in controller checking "find" method.is there code can used in model doesn't inserted.

perhaps use model events?

see docs here: https://laravel.com/docs/5.2/eloquent#events

so on post model following trigger when creating post:

public static function boot() {     parent::boot();      static::creating(function($post) {          // check foreign key validaty         // throw error if doesn't exist      }); } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -