check if there is any relationship
This commit is contained in:
parent
b6b7615c24
commit
49e9732fac
@ -87,14 +87,18 @@ class Controller extends BaseController
|
|||||||
* Mass delete relationships with events being fired.
|
* Mass delete relationships with events being fired.
|
||||||
*
|
*
|
||||||
* @param $model
|
* @param $model
|
||||||
* @param $tables
|
* @param $relationships
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function deleteRelationships($model, $tables)
|
public function deleteRelationships($model, $relationships)
|
||||||
{
|
{
|
||||||
foreach ((array) $tables as $table) {
|
foreach ((array) $relationships as $relationship) {
|
||||||
$items = $model->$table->all();
|
if (empty($model->$relationship)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $model->$relationship->all();
|
||||||
|
|
||||||
if ($items instanceof Collection) {
|
if ($items instanceof Collection) {
|
||||||
$items = $items->all();
|
$items = $items->all();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user