Basic bookmarks functionality

This commit is contained in:
Jonny Barnes 2017-10-10 15:58:07 +01:00
parent b840d164ed
commit 13e6ff1d0f
10 changed files with 173 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Bookmark::class, function (Faker $faker) {
return [
'url' => $faker->url,
'name' => $faker->sentence,
'content' => $faker->text,
];
});

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBookmarksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bookmarks', function (Blueprint $table) {
$table->increments('id');
$table->string('url');
$table->string('name')->nullable();
$table->text('content')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bookmarks');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBookmarkTagPivotTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bookmark_tag', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('bookmark_id');
$table->unsignedInteger('tag_id');
$table->timestamps();
$table->foreign('bookmark_id')->references('id')->on('bookmarks');
$table->foreign('tag_id')->references('id')->on('tags');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bookmark_tag');
}
}

View file

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class BookmarksTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Bookmark::class, 10)->create();
}
}

View file

@ -19,5 +19,6 @@ class DatabaseSeeder extends Seeder
$this->call(WebMentionsTableSeeder::class);
$this->call(IndieWebUserTableSeeder::class);
$this->call(LikesTableSeeder::class);
$this->call(BookmarksTableSeeder::class);
}
}