improved disable/delete with relationships

This commit is contained in:
denisdulici
2017-10-16 10:51:43 +03:00
parent ae52ce5a43
commit b1b36d8a64
16 changed files with 131 additions and 311 deletions

View File

@ -44,4 +44,17 @@ class Controller extends BaseController
$this->middleware('permission:update-' . $controller)->only(['update']);
$this->middleware('permission:delete-' . $controller)->only('destroy');
}
public function countRelationships($model, $relationships)
{
$counter = array();
foreach ($relationships as $relationship => $text) {
if ($c = $model->$relationship()->count()) {
$counter[] = $c . ' ' . strtolower(trans_choice('general.' . $text, ($c > 1) ? 2 : 1));
}
}
return $counter;
}
}