public function __construct($target) { $this->target = $target; Event::listen('eloquent.created:*', function ($model) use($target) { if (get_class($model) == get_class($target)) { Tattler::room($this->getRoom())->say($this->tattlerCollectMessageBag($model, 'crud_create')); } }); Event::listen('eloquent.updated:*', function ($model) use($target) { if (get_class($model) == get_class($target)) { Tattler::room($this->getRoom())->say($this->tattlerCollectMessageBag($model, 'crud_update')); } }); Event::listen('eloquent.deleted:*', function ($model) use($target) { if (get_class($model) == get_class($target)) { Tattler::room($this->getRoom())->say($this->tattlerCollectMessageBag($model, 'crud_delete')); } }); }
protected function inject($widget) { if (isset($widget->model) && method_exists($widget->model, 'isClassExtendedWith')) { if ($widget->model->isClassExtendedWith('\\Grohman\\Tattler\\Lib\\Inject') == false) { $widget->model->extendClassWith('\\Grohman\\Tattler\\Lib\\Inject'); } if (method_exists($widget, 'getColumns')) { $columns = $widget->model->getWidgetColumns($widget->getColumns()); } else { $columns = $widget->model->getWidgetColumns(); } if ($columns) { $room = Tattler::addRoom(get_class($widget->model)); $room->allow(); $user = Tattler::addUser(BackendAuth::getUser()); $user->allow(); $this->loadAssets($widget, Tattler::getDefaultRooms([$room->getName(), $user->getName()])); } } }
/** Отправка socketId и листинга запрашиваемых комнат * @param Request $request * @return mixed */ public function postIndex(Request $request) { return Tattler::getRooms($request->all()); }