commit 43bb92a928a5ee12089fa7db32547862c65a644f
Author: zabran <zabran@students.zcu.cz>
Date:   Mon Apr 6 14:30:56 2020 +0200

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

diff --git a/app/Artefact.php b/app/Artefact.php
index a14ebe9..0b52a4d 100644
--- a/app/Artefact.php
+++ b/app/Artefact.php
@@ -16,9 +16,9 @@ class Artefact extends Model
      *
      * @var array
      */
-    protected $attributes = [
+    /*protected $attributes = [
         'likes' => 0,
-    ];
+    ];*/
 
     /**
      * Indicates if the model should be timestamped.
@@ -36,22 +36,21 @@ class Artefact extends Model
     }
 
     /**
-     * Get the main category for the artefact.
+     * Get the categories for the artefact.
      */
-    public function main_category()
+    public function categories()
     {
-        return $this->hasOne('App\Category', 'main_category_id');
+        return $this->belongsToMany('App\Category');
     }
 
     /**
-     * Get the categories for the artefact.
+     * Get the users for the artefact.
      */
-    public function categories()
+    public function users()
     {
-        return $this->belongsToMany('App\Category');
+        return $this->belongsToMany('App\User');
     }
 
 
 
-
 }
diff --git a/app/Category.php b/app/Category.php
index 9fe6fb0..cb2d9c0 100644
--- a/app/Category.php
+++ b/app/Category.php
@@ -22,7 +22,7 @@ class Category extends Model
     /**
      * Get the artefacts for the catagory.
      */
-    public function atrefacts()
+    public function artefacts()
     {
         return $this->belongsToMany('App\Artefact');
     }
diff --git a/app/Metadata.php b/app/Metadata.php
index 529804e..ee2a148 100644
--- a/app/Metadata.php
+++ b/app/Metadata.php
@@ -16,9 +16,9 @@ class Metadata extends Model
      *
      * @var array
      */
-    protected $attributes = [
+    /*protected $attributes = [
         'likes' => 0,
-    ];
+    ];*/
 
     /**
      * Indicates if the model should be timestamped.
diff --git a/app/User.php b/app/User.php
index e79dab7..9e3eeb2 100644
--- a/app/User.php
+++ b/app/User.php
@@ -10,13 +10,18 @@ class User extends Authenticatable
 {
     use Notifiable;
 
+    // Table Name
+    protected $table = 'users';
+    // Primary Key
+    public $primaryKey = 'id';//unnecessery?
+
     /**
      * The attributes that are mass assignable.
      *
      * @var array
      */
     protected $fillable = [
-        'name', 'email', 'password',
+         'email',
     ];
 
     /**
@@ -25,7 +30,7 @@ class User extends Authenticatable
      * @var array
      */
     protected $hidden = [
-        'password', 'remember_token',
+        'remember_token',
     ];
 
     /**
@@ -36,4 +41,12 @@ class User extends Authenticatable
     protected $casts = [
         'email_verified_at' => 'datetime',
     ];
+
+    /**
+     * Get the artefacts for the user.
+     */
+    public function likes()
+    {
+        return $this->hasMany('App\Artefact');
+    }
 }
diff --git a/database/migrations/2020_03_20_000000_CreateArtefactCategoryTable.php b/database/migrations/2020_03_20_000000_CreateArtefactCategoryTable.php
deleted file mode 100644
index 84b419d..0000000
--- a/database/migrations/2020_03_20_000000_CreateArtefactCategoryTable.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateArtefactCategoryTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('artefact_category', function (Blueprint $table) {
-            $table->integer('artefact_id')->unsigned();;
-            $table->integer('catagory_id')->unsigned();;
-            $table->foreign('artefact_id')->references('id')->on('artefacts');
-            $table->foreign('category_id')->references('id')->on('categories');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('artefact_category');
-    }
-}
diff --git a/database/migrations/2020_03_20_000000_CreateArtefactsTable.php b/database/migrations/2020_03_20_000000_CreateArtefactsTable.php
index 5b32c35..f9750da 100644
--- a/database/migrations/2020_03_20_000000_CreateArtefactsTable.php
+++ b/database/migrations/2020_03_20_000000_CreateArtefactsTable.php
@@ -21,7 +21,7 @@ class CreateArtefactsTable extends Migration
             $table->string('publisher');
             $table->integer('year');
             $table->integer('pages');
-            $table->integer('likes');
+            //$table->integer('likes');
 
             $table->integer('main_category_id')->unsigned();
             $table->foreign('main_category_id')->references('id')->on('categories');
diff --git a/database/migrations/2020_03_20_000000_CreateMetadataTable.php b/database/migrations/2020_03_20_000000_CreateMetadataTable.php
index 3cbce77..30a24ca 100644
--- a/database/migrations/2020_03_20_000000_CreateMetadataTable.php
+++ b/database/migrations/2020_03_20_000000_CreateMetadataTable.php
@@ -23,7 +23,7 @@ class CreateMetadataTable extends Migration
             $table->longText('noteEN');
 
             $table->integer('page');
-            $table->integer('likes');
+            //$table->integer('likes');
         });
     }
 
diff --git a/database/migrations/2020_04_06_000000_CreateArtefactUserTable.php b/database/migrations/2020_04_06_000000_CreateArtefactUserTable.php
new file mode 100644
index 0000000..1673a19
--- /dev/null
+++ b/database/migrations/2020_04_06_000000_CreateArtefactUserTable.php
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateArtefactUserTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('artefact_user', function (Blueprint $table) {
+            $table->unsignedBigInteger('artefact_id');
+            $table->unsignedBigInteger('user_id');
+            $table->foreign('artefact_id')->references('id')->on('artefacts');
+            $table->foreign('user_id')->references('id')->on('users');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('artefact_user');
+    }
+}
diff --git a/database/migrations/2020_04_06_000000_CreateUsersTable.php b/database/migrations/2020_04_06_000000_CreateUsersTable.php
new file mode 100644
index 0000000..010b1e0
--- /dev/null
+++ b/database/migrations/2020_04_06_000000_CreateUsersTable.php
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateUsersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('users', function (Blueprint $table) {
+            $table->id();
+
+            $table->string('email')->unique();
+
+            $table->timestamp('email_verified_at')->nullable();
+            $table->rememberToken();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('users');
+    }
+}
