Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 43bb92a9

Přidáno uživatelem Marek Zábran před více než 4 roky(ů)

Úprava databáze - přidání uživatelů a reference lajků.
Issue #7787 @2h

Zobrazit rozdíly:

app/Artefact.php
16 16
     *
17 17
     * @var array
18 18
     */
19
    protected $attributes = [
19
    /*protected $attributes = [
20 20
        'likes' => 0,
21
    ];
21
    ];*/
22 22

  
23 23
    /**
24 24
     * Indicates if the model should be timestamped.
......
36 36
    }
37 37

  
38 38
    /**
39
     * Get the main category for the artefact.
39
     * Get the categories for the artefact.
40 40
     */
41
    public function main_category()
41
    public function categories()
42 42
    {
43
        return $this->hasOne('App\Category', 'main_category_id');
43
        return $this->belongsToMany('App\Category');
44 44
    }
45 45

  
46 46
    /**
47
     * Get the categories for the artefact.
47
     * Get the users for the artefact.
48 48
     */
49
    public function categories()
49
    public function users()
50 50
    {
51
        return $this->belongsToMany('App\Category');
51
        return $this->belongsToMany('App\User');
52 52
    }
53 53

  
54 54

  
55 55

  
56

  
57 56
}
app/Category.php
22 22
    /**
23 23
     * Get the artefacts for the catagory.
24 24
     */
25
    public function atrefacts()
25
    public function artefacts()
26 26
    {
27 27
        return $this->belongsToMany('App\Artefact');
28 28
    }
app/Metadata.php
16 16
     *
17 17
     * @var array
18 18
     */
19
    protected $attributes = [
19
    /*protected $attributes = [
20 20
        'likes' => 0,
21
    ];
21
    ];*/
22 22

  
23 23
    /**
24 24
     * Indicates if the model should be timestamped.
app/User.php
10 10
{
11 11
    use Notifiable;
12 12

  
13
    // Table Name
14
    protected $table = 'users';
15
    // Primary Key
16
    public $primaryKey = 'id';//unnecessery?
17

  
13 18
    /**
14 19
     * The attributes that are mass assignable.
15 20
     *
16 21
     * @var array
17 22
     */
18 23
    protected $fillable = [
19
        'name', 'email', 'password',
24
         'email',
20 25
    ];
21 26

  
22 27
    /**
......
25 30
     * @var array
26 31
     */
27 32
    protected $hidden = [
28
        'password', 'remember_token',
33
        'remember_token',
29 34
    ];
30 35

  
31 36
    /**
......
36 41
    protected $casts = [
37 42
        'email_verified_at' => 'datetime',
38 43
    ];
44

  
45
    /**
46
     * Get the artefacts for the user.
47
     */
48
    public function likes()
49
    {
50
        return $this->hasMany('App\Artefact');
51
    }
39 52
}
database/migrations/2020_03_20_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->integer('artefact_id')->unsigned();;
18
            $table->integer('catagory_id')->unsigned();;
19
            $table->foreign('artefact_id')->references('id')->on('artefacts');
20
            $table->foreign('category_id')->references('id')->on('categories');
21
        });
22
    }
23

  
24
    /**
25
     * Reverse the migrations.
26
     *
27
     * @return void
28
     */
29
    public function down()
30
    {
31
        Schema::dropIfExists('artefact_category');
32
    }
33
}
database/migrations/2020_03_20_000000_CreateArtefactsTable.php
21 21
            $table->string('publisher');
22 22
            $table->integer('year');
23 23
            $table->integer('pages');
24
            $table->integer('likes');
24
            //$table->integer('likes');
25 25

  
26 26
            $table->integer('main_category_id')->unsigned();
27 27
            $table->foreign('main_category_id')->references('id')->on('categories');
database/migrations/2020_03_20_000000_CreateMetadataTable.php
23 23
            $table->longText('noteEN');
24 24

  
25 25
            $table->integer('page');
26
            $table->integer('likes');
26
            //$table->integer('likes');
27 27
        });
28 28
    }
29 29

  
database/migrations/2020_04_06_000000_CreateArtefactUserTable.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 CreateArtefactUserTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('artefact_user', function (Blueprint $table) {
17
            $table->unsignedBigInteger('artefact_id');
18
            $table->unsignedBigInteger('user_id');
19
            $table->foreign('artefact_id')->references('id')->on('artefacts');
20
            $table->foreign('user_id')->references('id')->on('users');
21
        });
22
    }
23

  
24
    /**
25
     * Reverse the migrations.
26
     *
27
     * @return void
28
     */
29
    public function down()
30
    {
31
        Schema::dropIfExists('artefact_user');
32
    }
33
}
database/migrations/2020_04_06_000000_CreateUsersTable.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 CreateUsersTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('users', function (Blueprint $table) {
17
            $table->id();
18

  
19
            $table->string('email')->unique();
20

  
21
            $table->timestamp('email_verified_at')->nullable();
22
            $table->rememberToken();
23
            $table->timestamps();
24
        });
25
    }
26

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

Také k dispozici: Unified diff