Skip to content

Commit e9b6b05

Browse files
committed
Update MakeModel, added core config and added storage:link command
1 parent 0e891d0 commit e9b6b05

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

config/dbm.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,23 @@
162162
// Enable debug when developemnt mode. By default false
163163
'debug' => false,
164164
],
165+
/*
166+
|-------------------------------------------------------------
167+
| Core
168+
|-------------------------------------------------------------
169+
|
170+
| Here you can set backup config
171+
|
172+
*/
173+
'core' => [
174+
'tables' => [
175+
"dbm_objects",
176+
"dbm_fields",
177+
"dbm_permissions",
178+
"dbm_user_permissions",
179+
"dbm_collection_fields",
180+
"dbm_collections",
181+
"dbm_templates",
182+
],
183+
],
165184
];

src/Commands/InstallDatabaseManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ public function handle(Filesystem $filesystem)
6666
// Publish only relevant resources on install
6767
$tags = ['dbm.config'];
6868
$this->call('vendor:publish', ['--provider' => ManagerServiceProvider::class, '--tag' => $tags]);
69-
69+
// Create storage link
70+
$this->info('Generate storage link');
71+
$this->call('storage:link');
72+
// Migrate Database
7073
$this->info('Migrating the database tables into your application');
7174
$this->call('migrate', ['--force' => $this->option('force')]);
75+
//Install Passport
7276
$this->info('Install Passport');
7377
$this->call('passport:install', ['--force' => $this->option('force')]);
7478

src/Manager.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,23 @@ public function makeModel($model, $table)
113113
{
114114
try {
115115

116-
$partials = explode("\\", $model);
117-
116+
$partials = explode("\\", $model);
118117
$className = array_pop($partials);
119118
$namespace = implode("\\", $partials);
120119

120+
$app = array_shift($partials);
121+
$directory = implode(DIRECTORY_SEPARATOR, $partials);
122+
if (strtolower($app) != 'app') {
123+
$namespace = "App\\" . $namespace;
124+
$directory = $app . DIRECTORY_SEPARATOR . $directory;
125+
}
126+
127+
$path = app_path() . DIRECTORY_SEPARATOR . $directory;
128+
129+
if (!File::isDirectory($path)) {
130+
File::makeDirectory($path, 0777, true, true);
131+
}
132+
121133
$contents = "<?php\n\n";
122134
$contents .= "namespace " . $namespace . ";\n\n";
123135
if (Driver::isMongoDB()) {
@@ -137,7 +149,8 @@ public function makeModel($model, $table)
137149
$contents .= "}\n";
138150

139151
$filesystem = new Filesystem;
140-
$filesystem->put(base_path($model . ".php"), $contents);
152+
$filesystem->put($path . DIRECTORY_SEPARATOR . $className . ".php", $contents);
153+
141154
} catch (\Exception $e) {
142155
throw new \Exception("There has an error when create model. The error is :" . $e->getMessage(), 1);
143156

0 commit comments

Comments
 (0)