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:
Tony Murray
2019-01-17 09:00:25 -06:00
committed by GitHub
parent 10f6eac677
commit 3099b6793a
3 changed files with 55 additions and 0 deletions

View 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';
}
}

View File

@@ -20,4 +20,12 @@ class CliServiceProvider extends ArtisanServiceProvider
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']);
});
}
}

View File

@@ -59,3 +59,8 @@ Simple enough, this is where all of the rrd files are created. They are stored i
### database/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
```