delete with foreign data also using model laravel code example
Example 1: laravel remove foreign key
$table->dropForeign('posts_user_id_foreign');
Example 2: laravel delete relationship data
class User extends Eloquent
{
public function photos()
{
return $this->has_many('Photo');
}
// this is a recommended way to declare event handlers
public static function boot() {
parent::boot();
static::deleting(function($user) { // before delete() method call this
$user->photos()->delete();
// do the rest of the cleanup...
});
}
}