Skip to content

Commit

Permalink
feat: create migration and register in the provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Sep 23, 2024
1 parent b35cf66 commit fdde713
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
31 changes: 31 additions & 0 deletions migrations/2024_09_23_163615_create_likes_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('likes', function (Blueprint $table) {
$table->id();
$table->uuid();
$table->unsignedBigInteger('user_id');
$table->morphs('likeable');

$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('likes');
}
};
12 changes: 12 additions & 0 deletions src/Providers/LikeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LikeServiceProvider extends ServiceProvider
*/
public function boot(): void
{
$this->registerMigration();
}

/**
Expand All @@ -22,6 +23,7 @@ public function boot(): void
*/
public function register(): void
{
//
}

/**
Expand All @@ -33,4 +35,14 @@ public function provides(): ?array
{
return ['like'];
}

/**
* Register the package's migrations.
*
* @return void
*/
public function registerMigration(): void
{
$this->loadMigrationsFrom(__DIR__.'/../../migrations');
}
}

0 comments on commit fdde713

Please sign in to comment.