/** * * * @param array $attributes * @param $user */ public function assignRoutes(array $attributes = []) { if (array_key_exists('routes', $attributes) && is_array($attributes['routes']) && "" != $attributes['routes'][0]) { $this->clearRouteAssociation(); foreach ($attributes['routes'] as $id) { $route = \Etherbase\App\Models\Route::find($id); $this->routes()->save($route); } } else { $this->clearRouteAssociation(); } }