HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/fire-tech/fire-tech.nl/app/KommaApp/Kms/Core/Eav/Repository.php
<?php
namespace App\KommaApp\Kms\Core\Eav;

use Illuminate\Database\Eloquent\Model;

class Repository
{
    /**
     * Repository constructor.
     */
    public function __construct()
    {

    }


    public static function createTables(EntityInterface $entity, AttributeInterface $attribute, ValueInterface $value)
    {
        if(!is_a($entity, Model::class)) throw new \InvalidArgumentException("The entity model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");
        if(!is_a($attribute, Model::class)) throw new \InvalidArgumentException("The attribute model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");
        if(!is_a($value, Model::class)) throw new \InvalidArgumentException("The value model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");

        \Schema::create($entity->getTable(), function ($table) {
            $table->increments('id');
            $table->string('name');
            $table->timestamps();
        });

        \Schema::create($attribute->getTable(), function ($table) {
            $table->increments('id');
            $table->integer('entity_id')->nullable();
            $table->string('name');
            $table->timestamps();
        });

        \Schema::create($value->getTable(), function ($table) {
            $table->increments('id');
            $table->integer('attribute_id')->nullable();
            $table->integer('language_id')->nullable();
            $table->string('name');
            $table->timestamps();
        });
    }

    /**
     * Drops the tables as created with the createTables method.
     *
     * @see Repository::createTables()
     * @return $this
     */
    public static function dropTables(EntityInterface $entity, AttributeInterface $attribute, ValueInterface $value)
    {
        if(!is_a($entity, Model::class)) throw new \InvalidArgumentException("The entity model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");
        if(!is_a($attribute, Model::class)) throw new \InvalidArgumentException("The attribute model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");
        if(!is_a($value, Model::class)) throw new \InvalidArgumentException("The value model class must be a child instance of an eloquent model (Illuminate\Database\Eloquent\Model)");


        \Schema::drop($entity->getTable());
        \Schema::drop($attribute->getTable());
        \Schema::drop($value->getTable());
    }
}