From 5e4f12959e67658a703eb8e3faa5388deb1a4981 Mon Sep 17 00:00:00 2001 From: mahmoudmohamedramadan Date: Thu, 28 Sep 2023 17:49:34 +0200 Subject: [PATCH 1/2] Renders the `layout` variable --- src/Illuminate/Foundation/Console/stubs/view.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/stubs/view.stub b/src/Illuminate/Foundation/Console/stubs/view.stub index 6ecd80c26413..c26f3d58743b 100644 --- a/src/Illuminate/Foundation/Console/stubs/view.stub +++ b/src/Illuminate/Foundation/Console/stubs/view.stub @@ -1,3 +1,3 @@ -
+{{ layout }}
From 1a867acddd503bd8f7c9a1b0dbe7dcac06cf5fde Mon Sep 17 00:00:00 2001 From: mahmoudmohamedramadan Date: Thu, 28 Sep 2023 17:50:05 +0200 Subject: [PATCH 2/2] Adds the ability to specify the parent of the generated view --- src/Illuminate/Foundation/Console/ViewMakeCommand.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ViewMakeCommand.php b/src/Illuminate/Foundation/Console/ViewMakeCommand.php index 49899312c65d..f35130603ade 100644 --- a/src/Illuminate/Foundation/Console/ViewMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ViewMakeCommand.php @@ -47,11 +47,15 @@ class ViewMakeCommand extends GeneratorCommand protected function buildClass($name) { $contents = parent::buildClass($name); + $layout = $this->option('layout'); + + $replace = [ + '{{ layout }}' => $layout ? "@extends('{$layout}')\n\n" : null, + '{{ quote }}' => Inspiring::quotes()->random() + ]; return str_replace( - '{{ quote }}', - Inspiring::quotes()->random(), - $contents, + array_keys($replace), array_values($replace), $contents ); } @@ -229,6 +233,7 @@ protected function testViewName() protected function getOptions() { return [ + ['layout', null, InputOption::VALUE_OPTIONAL, 'The parent of the generated view', null], ['extension', null, InputOption::VALUE_OPTIONAL, 'The extension of the generated view', 'blade.php'], ['force', 'f', InputOption::VALUE_NONE, 'Create the view even if the view already exists'], ];