public function initialize() { parent::initialize(); $this->talk_id = self::TALK_ID_ALL; $this->to_id = self::TALK_ID_ALL; $this->to_user_info = self::USER_INFO_ALL; }
protected function initialize() { parent::initialize(); // check the if the requester has the `create` // permission before creating static::creating(function (ModelEvent $event) { $model = $event->getModel(); $permission = self::PERMISSION_CREATE; if (!$model->can($permission, ACLModel::getRequester())) { $model->errors()->add($permission, 'pulsar.validation.no_permission'); $event->stopPropagation(); } }, self::LISTENER_PRIORITY); // check the if the requester has the `edit` // permission before updating static::updating(function (ModelEvent $event) { $model = $event->getModel(); $permission = self::PERMISSION_UPDATE; if (!$model->can($permission, ACLModel::getRequester())) { $model->errors()->add($permission, 'pulsar.validation.no_permission'); $event->stopPropagation(); } }, self::LISTENER_PRIORITY); // check the if the requester has the `delete` // permission before deleting static::deleting(function (ModelEvent $event) { $model = $event->getModel(); $permission = self::PERMISSION_DELETE; if (!$model->can($permission, ACLModel::getRequester())) { $model->errors()->add($permission, 'pulsar.validation.no_permission'); $event->stopPropagation(); } }, self::LISTENER_PRIORITY); }