SeederCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace Wn\Generators\Commands;
2
3
4
class SeederCommand extends BaseCommand {
5
6
	protected $signature = 'wn:seeder
7
        {model : full qualified name of the model.}
8
        {--count=10 : number of elements to add in database.}
9
        {--force= : override the existing files}
10
    ';
11
12
	protected $description = 'Generates a seeder';
13
14
    public function handle()
15
    {
16
        $model = $this->argument('model');
17
        $name = $this->getSeederName($model);
18
        $file = "./database/seeds/{$name}.php";
19
20
        $content = $this->getTemplate('seeder')
21
            ->with([
22
                'model' => $model,
23
                'name' => $name,
24
                'count' => $this->option('count')
25
            ])
26
            ->get();
27
28
29
        $this->save($content, $file, $name);
30
    }
31
32
    protected function getSeederName($name)
33
    {
34
        $name = explode("\\", $name);
35
        $name = ucwords(\Illuminate\Support\Str::plural($name[count($name) - 1]));
36
        $name = $name . 'TableSeeder';
37
        return $name;
38
    }
39
40
}
41