mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Make Eloquent models in the correct place (#9681)
* Make Eloquent models in the correct place * Docs to indicate what command should be run to make a new table
This commit is contained in:
42
app/Console/ModelMakeCommand.php
Normal file
42
app/Console/ModelMakeCommand.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ModelMakeCommand.php
|
||||||
|
*
|
||||||
|
* -Description-
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @package LibreNMS
|
||||||
|
* @link http://librenms.org
|
||||||
|
* @copyright 2019 Tony Murray
|
||||||
|
* @author Tony Murray <murraytony@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Console\ModelMakeCommand as LaravelModelMakeCommand;
|
||||||
|
|
||||||
|
class ModelMakeCommand extends LaravelModelMakeCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the default namespace for the class.
|
||||||
|
*
|
||||||
|
* @param string $rootNamespace
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getDefaultNamespace($rootNamespace)
|
||||||
|
{
|
||||||
|
return $rootNamespace.'\Models';
|
||||||
|
}
|
||||||
|
}
|
@@ -20,4 +20,12 @@ class CliServiceProvider extends ArtisanServiceProvider
|
|||||||
parent::register();
|
parent::register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function registerModelMakeCommand()
|
||||||
|
{
|
||||||
|
// override with our own implementation to put models in the correct namespace
|
||||||
|
$this->app->singleton('command.model.make', function ($app) {
|
||||||
|
return new \App\Console\ModelMakeCommand($app['files']);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,3 +59,8 @@ Simple enough, this is where all of the rrd files are created. They are stored i
|
|||||||
|
|
||||||
### database/migrations
|
### database/migrations
|
||||||
Contains all the database migrations. See Laravel docs for additional info: https://laravel.com/docs/migrations
|
Contains all the database migrations. See Laravel docs for additional info: https://laravel.com/docs/migrations
|
||||||
|
|
||||||
|
In general to create a new table you should run:
|
||||||
|
```bash
|
||||||
|
php artisan make:model ModelName -m -c -r
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user