1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelZero\Framework\Commands\Component\Illuminate\Database; |
4
|
|
|
|
5
|
|
|
use LaravelZero\Framework\Commands\Component\Installer as BaseInstaller; |
6
|
|
|
use LaravelZero\Framework\Contracts\Providers\Composer as ComposerContract; |
7
|
|
|
use LaravelZero\Framework\Contracts\Commands\Component\Installer as InstallerContract; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This is the Laravel Zero Framework illuminate/database install class. |
11
|
|
|
* |
12
|
|
|
* @author Nuno Maduro <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class Installer extends BaseInstaller implements InstallerContract |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
|
|
protected $name = 'install:database'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Installs illuminate/database - Eloquent'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function getComponentName(): string |
30
|
|
|
{ |
31
|
|
|
return 'database'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function install(): bool |
38
|
|
|
{ |
39
|
|
|
$composer = $this->getContainer() |
40
|
|
|
->make(ComposerContract::class); |
41
|
|
|
|
42
|
|
|
$this->info('Pulling illuminate/database...'); |
43
|
|
|
$composer->require('illuminate/database "5.5.*"'); |
44
|
|
|
$composer->require('illuminate/filesystem "5.5.*"'); |
45
|
|
|
|
46
|
|
|
$this->info('Creating (database/database.sqlite)...'); |
47
|
|
|
shell_exec('cd '.BASE_PATH.'&& mkdir database && touch database/database.sqlite'); |
48
|
|
|
shell_exec('cd '.BASE_PATH.'/database && mkdir migrations'); |
49
|
|
|
|
50
|
|
|
$this->info('Copying default config...'); |
51
|
|
|
shell_exec('cp -n '.__DIR__.'/config/database.php '.config_path('database.php')); |
52
|
|
|
|
53
|
|
|
$this->info('Component installed! Usage:'); |
54
|
|
|
$this->comment( |
55
|
|
|
' |
56
|
|
|
|
57
|
|
|
use Illuminate\Support\Facades\DB; |
58
|
|
|
use Illuminate\Support\Facades\Schema; |
59
|
|
|
|
60
|
|
|
Schema::create(\'users\', function ($table) { |
61
|
|
|
$table->increments(\'id\'); |
62
|
|
|
$table->string(\'email\')->unique(); |
63
|
|
|
$table->timestamps(); |
64
|
|
|
}); |
65
|
|
|
|
66
|
|
|
DB::table(\'users\')->insert( |
67
|
|
|
[\'email\' => \'[email protected]\'] |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
$users = DB::table(\'users\')->get(); |
71
|
|
|
|
72
|
|
|
dd($users); |
73
|
|
|
|
74
|
|
|
' |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
return true; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|