Skip to content

Commit e52e106

Browse files
committed
Fix #114
1 parent 0050b4b commit e52e106

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "crestapps/laravel-code-generator",
33
"license": "MIT",
44
"description": "An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.",
5-
"version": "v2.3.1",
5+
"version": "v2.3.2",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

src/Commands/Resources/ResourceFileCreateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function handle()
7070
$resource = new Resource($fields, $relations, $indexes);
7171

7272
$resource->setDefaultApiDocLabels($input->modelName, self::makeLocaleGroup($input->modelName), $input->translationFor);
73-
73+
7474
$this->createFile($file, Helpers::prettifyJson($resource->toArray()))
7575
->info('The "' . basename($file) . '" file was crafted successfully!');
7676
}

src/Support/ResourceMapper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
use Exception;
88
use File;
99
use Illuminate\Console\Command;
10+
use CrestApps\CodeGenerator\Traits\CommonCommand;
1011

1112
class ResourceMapper
1213
{
14+
use CommonCommand;
15+
1316
/**
1417
* @param Illuminate\Console\Command
1518
*/
@@ -136,8 +139,8 @@ public function append($modelName, $fieldsFileName, $tableName = null)
136139
$finalMaps[] = (object) $existingMap;
137140
}
138141
}
139-
140-
File::put($file, Helpers::prettifyJson($finalMaps));
142+
143+
$this->putContentInFile($file, Helpers::prettifyJson($finalMaps));
141144
}
142145

143146
/**

src/Traits/CommonCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,13 @@ protected function deleteFile($file)
399399
*/
400400
protected function putContentInFile($file, $content)
401401
{
402-
$bytesWritten = File::put($file, $content);
402+
$path = dirname($file);
403+
404+
if(!$this->isFileExists($path)) {
405+
File::makeDirectory($path, 0755, true);
406+
}
407+
408+
File::put($file, $content);
403409

404410
return $this;
405411
}
@@ -413,7 +419,7 @@ protected function putContentInFile($file, $content)
413419
*/
414420
protected function appendContentToFile($file, $content)
415421
{
416-
$bytesWritten = File::append($file, $content);
422+
File::append($file, $content);
417423

418424
return $this;
419425
}

0 commit comments

Comments
 (0)