id; $data['store_policy'] = $policy?->id; $data['update_policy'] = $policy?->id; $data['get_policy'] = $policy?->id; $data['delete_policy'] = $policy?->id; $data['restore_policy'] = $policy?->id; $data['trash_policy'] = $policy?->id; return ModelDocument::factory()->create($data); } protected function guessModelName($name): string { $name = explode('.', $name); $name = count($name) > 2 ? $name[1] : $name[0]; return Str::singular($name); } protected function provideDynamicModel(string|null $modelName = null, array $needs = []) { throw_if(empty($modelName), 'name must be provided.'); return $this->makeModel(Str::singular($modelName), $this->one(PolicyDocument::class, ['needs' => [$needs]])); } protected function modelWithPolicy($modelName = null, $needs) { $this->provideDynamicModel($modelName, $needs); return $this; } }