/** * Remove the event given the eventID. * @param int $id * @return Response */ public function destroy($id) { if (!Entrust::hasRole(RoleNames::EventManager($id))) { return response("Permission not found", 403); } return DB::transaction(function () use($id) { $event = Event::find($id); if (is_null($event)) { return response("No event for id {$id}.", 404); } $event->delete(); Permission::whereIn('name', PermissionNames::AllEventPermissions($id))->delete(); RoleCreate::deleteEventRoles($id); return response()->json(['id' => $event->id]); }); }
public static function EventManager($eventId, $permissions) { return DB::transaction(function () use($eventId, $permissions) { $rolename = RoleNames::EventManager($eventId); $role = new Role(); $role->name = $rolename; $role->save(); $role->attachPermissions($permissions); return $role; }); }