1 | <?php |
||||
2 | |||||
3 | namespace Glorand\Model\Settings\Console; |
||||
4 | |||||
5 | use Illuminate\Console\Command; |
||||
0 ignored issues
–
show
|
|||||
6 | use Illuminate\Filesystem\Filesystem; |
||||
0 ignored issues
–
show
The type
Illuminate\Filesystem\Filesystem was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||||
7 | use Illuminate\Support\Str; |
||||
8 | use Schema; |
||||
9 | |||||
10 | class CreateSettingsFieldForModel extends Command |
||||
11 | { |
||||
12 | /** @var string */ |
||||
13 | protected $signature = 'model-settings:model-settings-field'; |
||||
14 | |||||
15 | /** @var string */ |
||||
16 | protected $description = 'Create migration for the (update) selected table, adding settings field'; |
||||
17 | |||||
18 | /** |
||||
19 | * @param \Illuminate\Filesystem\Filesystem $file |
||||
20 | * @return bool |
||||
21 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
||||
22 | */ |
||||
23 | public function handle(Filesystem $file) |
||||
24 | { |
||||
25 | $table = strtolower($this->ask('What is the name of the table?')); |
||||
26 | $table = Str::snake(trim($table)); |
||||
27 | if (empty($table)) { |
||||
28 | $this->error('The name of the table is required!'); |
||||
29 | |||||
30 | return false; |
||||
31 | } |
||||
32 | $fieldName = 'settings'; |
||||
33 | if (!Schema::hasTable($table)) { |
||||
34 | $this->error('Unable to find table "' . $table . '" on the current DB!'); |
||||
35 | |||||
36 | return false; |
||||
37 | } |
||||
38 | if (Schema::hasColumn($table, $fieldName)) { |
||||
39 | $this->error('Field "' . $fieldName . '" already exists on table "' . $table . '"'); |
||||
40 | |||||
41 | return false; |
||||
42 | } |
||||
43 | |||||
44 | $fileName = date('Y_m_d_His') . '_update_' . $table . '_table_add_' . $fieldName . '.php'; |
||||
45 | $path = database_path('migrations') . '/' . $fileName; |
||||
0 ignored issues
–
show
The function
database_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
46 | $className = 'Update' . ucfirst($table) . 'TableAddSettings'; |
||||
47 | |||||
48 | |||||
49 | $stub = $file->get(__DIR__ . '/../../stubs/create_settings_field.stub'); |
||||
50 | $stub = str_replace('DummyClass', $className, $stub); |
||||
51 | $stub = str_replace('DummyTable', $table, $stub); |
||||
52 | $stub = str_replace('settingsFieldName', $fieldName, $stub); |
||||
53 | |||||
54 | $file->put($path, $stub); |
||||
55 | |||||
56 | $this->line("<info>Created Migration:</info> {$fileName}"); |
||||
57 | |||||
58 | return true; |
||||
59 | } |
||||
60 | } |
||||
61 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths