Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
laravel:beispiel [2019/09/08 20:35] webproducer angelegt |
laravel:beispiel [2019/09/29 09:56] (aktuell) webproducer Quellcode-Korrektur |
||
|---|---|---|---|
| Zeile 8: | Zeile 8: | ||
| <code php>php artisan make:migration create_bundeslaender_table</code> | <code php>php artisan make:migration create_bundeslaender_table</code> | ||
| + | |||
| + | **Tipp für PhpStorm-Nutzer:** Die Artisan-Kommandos können direkt in PhpStorm ausgeführt werden. Hierfür einfach mit der Tastenkombination [Alt] + [F12] das Terminal und anschließend mit dem "+" eine neue Session öffnen. | ||
| Die neu im Verzeichnis "database\migrations\" von artisan angelegte Migration kann jetzt wie im folgenden Beispiel angepasst werden: | Die neu im Verzeichnis "database\migrations\" von artisan angelegte Migration kann jetzt wie im folgenden Beispiel angepasst werden: | ||
| <code php> | <code php> | ||
| - | /** | + | public function up() |
| - | * Run the migrations. | + | { |
| - | * | + | Schema::create('bundeslaender', function (Blueprint $table) { |
| - | * @return void | + | $table->bigIncrements('id' ); |
| - | */ | + | $table->string( 'Bundeslandkuerzel', 2 ); |
| - | public function up() | + | $table->string( 'Bundesland', 25 ); |
| - | { | + | $table->float( 'Bearbeitungsgebuehr' ); |
| - | Schema::create('bundeslaender', function (Blueprint $table) { | + | }); |
| - | $table->string('ID', 2 ) -> unique(); | + | } |
| - | $table->string( 'Bundesland', 25 ); | + | |
| - | $table->float( 'Bearbeitungsgebuehr' ); | + | |
| - | }); | + | |
| - | } | + | |
| </code> | </code> | ||
| Zeile 55: | Zeile 53: | ||
| <code php> | <code php> | ||
| - | /** | + | public function run() |
| - | * Run the database seeds. | + | { |
| - | * | + | DB::table( 'bundeslaender' ) -> delete(); |
| - | * @return void | + | DB::table( 'bundeslaender' ) -> insert( array( |
| - | */ | + | 0 => array( |
| - | public function run() | + | 'Bundeslandkuerzel' => 'BW', |
| - | { | + | 'Bundesland' => 'Baden Würtemmberg', |
| - | DB::table( 'bundeslaender' ) -> delete(); | + | 'Bearbeitungsgebuehr' => 0.2 |
| - | DB::table( 'bundeslaender' ) -> insert( array( | + | ), |
| - | 0 => array( | + | 1 => array( |
| - | 'ID' => 'BW', | + | 'Bundeslandkuerzel' => 'BY', |
| - | 'Bundesland' => 'Baden Würtemmberg', | + | 'Bundesland' => 'Bayern', |
| - | 'Bearbeitungsgebuehr' => 0.2 | + | 'Bearbeitungsgebuehr' => 0.25 |
| - | ), | + | ), |
| - | 1 => array( | + | 2 => array( |
| - | 'ID' => 'BY', | + | 'Bundeslandkuerzel' => 'BE', |
| - | 'Bundesland' => 'Bayern', | + | 'Bundesland' => 'Berlin', |
| - | 'Bearbeitungsgebuehr' => 0.25 | + | 'Bearbeitungsgebuehr' => 0.5 |
| - | ), | + | ) |
| - | 2 => array( | + | )); |
| - | 'ID' => 'BE', | + | } |
| - | 'Bundesland' => 'Berlin', | + | |
| - | 'Bearbeitungsgebuehr' => 0.5 | + | |
| - | ) | + | |
| - | )); | + | |
| - | } | + | |
| </code> | </code> | ||
| Zeile 86: | Zeile 79: | ||
| <code php> | <code php> | ||
| - | /** | + | public function run() |
| - | * Seed the application's database. | + | { |
| - | * | + | $this->call(BundeslaenderTableSeeder::class ); |
| - | * @return void | + | } |
| - | */ | + | |
| - | public function run() | + | |
| - | { | + | |
| - | $this->call(BundeslaenderTableSeeder::class ); | + | |
| - | } | + | |
| </code> | </code> | ||