permissions on Twill

Good morning. Tell me how to properly allow a user with a specific role to perform certain actions? I have a user role and I want him to be able to post only articles. Thought to override the method. But instead of publishing, an edit action is available. protected function getIndexOption($option) { if (Auth::guard('twill_users')->user()->can('reviewer-permission')) { $authorizableOptions = [ 'publish' => 'publish', ]; } $authorized = array_key_exists($option, $authorizableOptions) ? Auth::guard('twill_users')->user()->can($authorizableOptions[$option]) : true; return ($this->indexOptions[$option] ?? $this->defaultIndexOptions[$option] ?? false) && $authorized; }
1 Reply
trompix
trompix3y ago
found the answer: protected function getIndexOption($option) { if (in_array($option, ['publish', 'edit'])) { return Auth::guard('twill_users')->user()->can('reviewer-permission'); } return parent::getIndexOption($option); }
Want results from more Discord servers?
Add your server