-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create migration for profile links #34
- Loading branch information
1 parent
ad3c912
commit d308b57
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
database/migrations/2016_01_01_100000_create_profile_links_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
}); | ||
} | ||
} |