Skip to content

Commit

Permalink
check if there is any relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Sep 1, 2018
1 parent b6b7615 commit 49e9732
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@ public function checkApiToken()
* Mass delete relationships with events being fired.
*
* @param $model
* @param $tables
* @param $relationships
*
* @return void
*/
public function deleteRelationships($model, $tables)
public function deleteRelationships($model, $relationships)
{
foreach ((array) $tables as $table) {
$items = $model->$table->all();
foreach ((array) $relationships as $relationship) {
if (empty($model->$relationship)) {
continue;
}

$items = $model->$relationship->all();

if ($items instanceof Collection) {
$items = $items->all();
Expand Down

0 comments on commit 49e9732

Please sign in to comment.