/**
  * Generate the file.
  *
  * @param $name
  * @return Policy|bool
  * @throws Exception
  */
 public function generate($name)
 {
     $policy = Str::policy($name);
     $path = $this->findPolicyPath($policy);
     if ($this->exists($path)) {
         throw new Exception('Policy already exists');
         return false;
     }
     $this->createPolicyDirectory();
     $namespace = $this->findPolicyNamespace();
     $content = file_get_contents($this->getStub());
     $content = str_replace(['{{policy}}', '{{namespace}}', '{{foundation_namespace}}'], [$policy, $namespace, $this->findFoundationNamespace()], $content);
     $this->createFile($path, $content);
     return new Policy($policy, $namespace, basename($path), $path, $this->relativeFromReal($path), $content);
 }
 /**
  * Parse the model name.
  *
  * @param string $name
  * @return string
  */
 public function parsePolicyName($name)
 {
     return Str::policy($name);
 }