示例#1
0
 public function handle()
 {
     $name = $this->ask('Directory name');
     $displayName = $this->ask('Display name');
     $name = Str::slugify($name);
     $destPath = Path::join(config('codex.root_dir'), $name);
     $fs = $this->getLaravel()->make('fs');
     if ($fs->exists($destPath)) {
         return $this->error("Could not create {$name}. Already exists");
     }
     $this->getLaravel()->make(ProjectGenerator::class)->setDestPath($destPath)->generateProject($name, $displayName);
     $this->comment('All done sire!');
 }
 protected function write($content, $name = null)
 {
     $tmpDir = storage_path('blade-extensions');
     if (!$this->files->exists($tmpDir)) {
         $this->files->makeDirectory($tmpDir);
     }
     if (is_null($name)) {
         $name = Str::slugify($this->viewPath) . '__' . uniqid(time(), true);
     }
     $path = Path::join($tmpDir, $name);
     $this->files->put($path, $content);
     return [$name, $path];
 }
示例#3
0
 public function testStringsCanBeSlugged()
 {
     $this->assertEquals('my-new-post', Str::slugify('My_nEw\\\\/  @ post!!!'));
     $this->assertEquals('my_new_post', Str::slugify('My nEw post!!!', '_'));
 }