Skip to content

Commit

Permalink
Quick bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminhansen committed Mar 25, 2024
1 parent aa0a06b commit 5024c88
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/MakeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function handle()
$empty = $this->option('empty');

$view_path = resource_path('views');
$viewname = str_replace('..', '.', $viewname);

// handle the actual file creation for the given blade view
if(str_contains($viewname, '.')) {
Expand All @@ -51,8 +50,8 @@ public function handle()
$count = count($parts);

// get the last element of the array, which is our blade view file
$blade_el = strtolower(end($parts));
$blade_file = "{$blade_el}.blade.php";
$blade_template = strtolower(end($parts));
$blade_file = "{$blade_template}.blade.php";

// loop over the entire array, except for the last element (which is the actual file)
// and create the necessary directories
Expand All @@ -68,24 +67,25 @@ public function handle()
$full_view_path = "{$folder}/{$blade_file}";
if(!file_exists($full_view_path)) {
touch($full_view_path);
$this->info("View [$viewname] created successfully!");
} else {
$this->error("View [$viewname] already exists!");
return;
}
} else {
// we are dealing with a single/top-level blade file
$blade_file = "{$viewname}.blade.php";
$full_view_path = "{$view_path}/{$blade_file}";
if(!file_exists($full_view_path)) {
touch($full_view_path);
$this->info("Empty view [$viewname] created successfully!");
} else {
$this->error("View [$viewname] already exists!");
return;
}
}

if($empty || !$extends) {
// if we are creating an empty view file, bail out here
$this->info("Empty view [$viewname] created successfully!");
return;
}

Expand Down

0 comments on commit 5024c88

Please sign in to comment.