michaeldyrynda/laravel-cascade-soft-deletes

Invalid argument supplied for foreach()

Langstra opened this issue · 0 comments

I have a structure where I have candidates, consultants, managers and customers in a system. Each of these 4 objects has a user. So a user can either be a candidate, consultant, manager or customer. This means that 3 of the 4 relation attributes will return null instead of an object.

I have the following settings in my user model.

use SoftDeletes, CascadeSoftDeletes;

    protected $cascadeDeletes = ['candidate', 'consultant', 'customer', 'manager'];

Now I get this error. I tested removing a candidate and filled the $cascadeDeletes with only candidate and then I got this error #10, but you are already working on it I saw. This is indeed a one-on-one relation.

in CascadeSoftDeletes.php line 39
at HandleExceptions->handleError('2', 'Invalid argument supplied for foreach()', '/home/langstra/Documents/work/randstad/ttempp/vendor/iatstuti/laravel-cascade-soft-deletes/src/CascadeSoftDeletes.php', '39', array('model' => object(User), 'invalidCascadingRelationships' => array(), 'delete' => 'delete', 'relationship' => 'candidate')) in CascadeSoftDeletes.php line 39
at User::Iatstuti\Database\Support\{closure}(object(User))
at call_user_func_array(object(Closure), array(object(User))) in Dispatcher.php line 221
at Dispatcher->fire('eloquent.deleting: Ttempp\Models\User', array(object(User)), true) in Dispatcher.php line 164
at Dispatcher->until('eloquent.deleting: Ttempp\Models\User', object(User)) in Model.php line 1686
at Model->fireModelEvent('eloquent.deleting: Ttempp\Models\User') in Model.php line 1122