Skip to content

Commit

Permalink
Create migration for profile links #34
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts authored Feb 27, 2021
1 parent ad3c912 commit d308b57
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Tipoff\Seo\Models\Webpage;

class CreateProfileLinksTable extends Migration
{
public function up()
{
Schema::create('profile_links', function (Blueprint $table) {
$table->id();
$table->string('type')->index(); // Example: 'Website', 'Facebook', 'Twitter', 'Instagram'
$table->foreignIdFor(Webpage::class)->index();
$table->morphs('profileable'); // Allows relations to User, Company, Location and other profiles

$table->unsignedTinyInteger('priority')->default(100); // For cases where want to list links in an order (by priority sorted ASC from low to high)

$table->foreignIdFor(app('user'), 'creator_id');
$table->foreignIdFor(app('user'), 'updater_id');
$table->timestamps();

$table->unique(['type', 'profileable_id', 'profileable_type']);
});
}
}

0 comments on commit d308b57

Please sign in to comment.