|string> */ public function rules(): array { $rule = []; if ($this->method() == "POST") { $rule = [ ...$rule, 'object_type' => [ 'required', new Enum(ApprovalObjectType::class), ], 'object_id' => [ 'required', function ($attribute, $value, $fail) { $exist = ApprovalObjectType::from($this->get("object_type")) ->modelBuilderAllowed($value) ->where("company_id", Auth::user()->company_id) ->where('id', $value) ->count(); if (! $exist) { $fail('Resources without permission to access.'); } } ] ]; } return $rule; } }