Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 41eaf441

Přidáno uživatelem Adam Mištera před více než 4 roky(ů)

Issue #7692 @1h

[+] Dokončení modelu, úprava readme.

Zobrazit rozdíly:

README.md
20 20
1. Zajistěte databázi se spojením určeným v souboru `.env`.
21 21
2. Spusťte v terminálu (PHPStorm nebo cmd ve složce projektu) příkaz `php artisan migrate`.
22 22

  
23
###### SQLite databáze
24

  
25
1. Soubor SQLite datábaze umístěte do `database\database.sqlite` (může to být i nový prázdný soubor).
26
2. Pro připojení k databázi je v potřeba v souboru `.env` nastavit `DB_CONNECTION=sqlite` (ostatní nastavení pro databázi odstranit).
27
3. Pro **čistou** migraci spusťte příkaz `php artisan migrate:fresh`.
database/migrations/2020_03_20_000000_CreateArtefactsTable.php
1
<?php
2

  
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6

  
7
class CreateArtefactsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('artefacts', function (Blueprint $table) {
17
            $table->id();
18
            $table->string('name');
19
            $table->string('author');
20
            $table->string('made_in');
21
            $table->string('publisher');
22
            $table->integer('year');
23
            $table->integer('pages');
24
            $table->integer('likes');
25
        });
26
    }
27

  
28
    /**
29
     * Reverse the migrations.
30
     *
31
     * @return void
32
     */
33
    public function down()
34
    {
35
        Schema::dropIfExists('artefacts');
36
    }
37
}
database/migrations/2020_03_20_000000_create_artefacts_table.php
1
<?php
2

  
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6

  
7
class CreateArtefactsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('artefacts', function (Blueprint $table) {
17
            $table->id();
18
            $table->string('name');
19
            $table->string('author');
20
            $table->string('made_in');
21
            $table->string('publisher');
22
            $table->integer('year');
23
            $table->integer('pages');
24
            $table->integer('likes');
25
        });
26
    }
27

  
28
    /**
29
     * Reverse the migrations.
30
     *
31
     * @return void
32
     */
33
    public function down()
34
    {
35
        Schema::dropIfExists('artefacts');
36
    }
37
}
database/migrations/2020_03_22_000000_CreateArtefactCategoryTable.php
1
<?php
2

  
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6

  
7
class CreateArtefactCategoryTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('artefact_category', function (Blueprint $table) {
17
            $table->unsignedBigInteger('artefact_id');
18
            $table->unsignedBigInteger('category_id');
19
            $table->foreign('artefact_id')->references('id')->on('artefacts');
20
            $table->foreign('category_id')->references('id')->on('categories');
21

  
22
        });
23
    }
24

  
25
    /**
26
     * Reverse the migrations.
27
     *
28
     * @return void
29
     */
30
    public function down()
31
    {
32
        Schema::dropIfExists('artefact_category');
33
    }
34
}

Také k dispozici: Unified diff