diff --git a/.gitignore b/.gitignore index c4bdd567..05d17c01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor .phpunit.result.cache composer.lock -openapi.json \ No newline at end of file +openapi.json +.DS_Store diff --git a/database/migrations/2022_04_11_095716_change_hh5p_contents_libraries_structure_table.php b/database/migrations/2022_04_11_095716_change_hh5p_contents_libraries_structure_table.php new file mode 100644 index 00000000..300c8b67 --- /dev/null +++ b/database/migrations/2022_04_11_095716_change_hh5p_contents_libraries_structure_table.php @@ -0,0 +1,75 @@ +dropPrimary('hh5p_contents_libraries_pkey'); + $table->unique(['content_id', 'library_id', 'dependency_type'], 'hh5p_contents_libraries_unique_key'); + }); + Schema::table('hh5p_contents_libraries', function (Blueprint $table) { + $table->id(); + }); + Schema::table('hh5p_libraries_languages', function (Blueprint $table) { + $table->dropPrimary('hh5p_libraries_languages_pkey'); + $table->unique(['library_id', 'language_code'], 'hh5p_libraries_languages_unique_key'); + }); + Schema::table('hh5p_libraries_languages', function (Blueprint $table) { + $table->id(); + }); + Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) { + $table->dropPrimary('hh5p_libraries_dependencies_pkey'); + $table->unique(['library_id', 'required_library_id'], 'hh5p_libraries_dependencies_unique_key'); + }); + Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) { + $table->id(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('hh5p_contents_libraries', function (Blueprint $table) { + $table->dropColumn('id'); + }); + Schema::table('hh5p_contents_libraries', function (Blueprint $table) { + $table->dropUnique('hh5p_contents_libraries_unique_key'); + }); + Schema::table('hh5p_libraries_languages', function (Blueprint $table) { + $table->dropUnique('hh5p_libraries_languages_unique_key'); + }); + Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) { + $table->dropUnique('hh5p_libraries_dependencies_unique_key'); + }); + Schema::table('hh5p_contents_libraries', function (Blueprint $table) { + $table->primary(['content_id', 'library_id', 'dependency_type'], 'fk_primary'); + }); + Schema::table('hh5p_libraries_languages', function (Blueprint $table) { + $table->dropColumn('id'); + }); + Schema::table('hh5p_libraries_languages', function (Blueprint $table) { + $table->primary(['library_id', 'language_code'], 'fk_primary'); + }); + Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) { + $table->dropColumn('id'); + }); + Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) { + $table->primary(['library_id', 'required_library_id'], 'fk_primary'); + }); + } +} diff --git a/phpunit.xml b/phpunit.xml index 1281b423..2f3c31a3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,14 +11,14 @@ ./tests - - - - - - - - - - + + + + + + + + + + diff --git a/src/Models/H5PContent.php b/src/Models/H5PContent.php index 6a52d03b..45b4b73d 100644 --- a/src/Models/H5PContent.php +++ b/src/Models/H5PContent.php @@ -2,7 +2,7 @@ namespace EscolaLms\HeadlessH5P\Models; -use App\User; +use EscolaLms\Core\Models\User; use EscolaLms\HeadlessH5P\Database\Factories\H5PContentFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; diff --git a/src/Models/H5PContentLibrary.php b/src/Models/H5PContentLibrary.php index a8871411..17a18f4b 100644 --- a/src/Models/H5PContentLibrary.php +++ b/src/Models/H5PContentLibrary.php @@ -12,8 +12,6 @@ class H5PContentLibrary extends Model protected $table = 'hh5p_contents_libraries'; - protected $primaryKey = ['content_id', 'library_id', 'dependency_type']; - protected $fillable = [ 'content_id', 'library_id', diff --git a/src/Models/H5PLibrary.php b/src/Models/H5PLibrary.php index d9446d3c..fa98eff1 100644 --- a/src/Models/H5PLibrary.php +++ b/src/Models/H5PLibrary.php @@ -118,7 +118,6 @@ class H5PLibrary extends Model use HasFactory; protected $table = 'hh5p_libraries'; - //protected $primaryKey = 'id'; protected $fillable = [ 'name', 'title', diff --git a/src/Models/H5PLibraryDependency.php b/src/Models/H5PLibraryDependency.php index 790d459a..b48c4b90 100644 --- a/src/Models/H5PLibraryDependency.php +++ b/src/Models/H5PLibraryDependency.php @@ -12,8 +12,6 @@ class H5PLibraryDependency extends Model public $timestamps = false; protected $table = 'hh5p_libraries_dependencies'; - - protected $primaryKey = ['library_id', 'required_library_id']; protected $fillable = [ 'library_id', diff --git a/src/Models/H5PLibraryLanguage.php b/src/Models/H5PLibraryLanguage.php index e34b7450..921872f6 100644 --- a/src/Models/H5PLibraryLanguage.php +++ b/src/Models/H5PLibraryLanguage.php @@ -12,8 +12,6 @@ class H5PLibraryLanguage extends Model public $timestamps = false; protected $table = 'hh5p_libraries_languages'; - - protected $primaryKey = ['library_id', 'language_code']; protected $fillable = [ 'library_id', @@ -26,7 +24,7 @@ public function getTranslationAttribute($value) { return json_decode($value); } - + public function library():BelongsTo { diff --git a/src/Models/H5PTempFile.php b/src/Models/H5PTempFile.php index c56076f6..436ab3ec 100644 --- a/src/Models/H5PTempFile.php +++ b/src/Models/H5PTempFile.php @@ -7,7 +7,6 @@ class H5PTempFile extends Model { - protected $primaryKey = 'id'; protected $table = 'hh5p_temp_files'; protected $fillable = [ 'path',