Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/Models/Bookmark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Bookmark extends Model
{
use HasFactory;

public function post(): BelongsTo
{
return $this->belongsTo(Post::class);
}

public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
25 changes: 25 additions & 0 deletions database/factories/BookmarkFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Database\Factories;

use App\Models\Bookmark;
use App\Models\Post;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;

class BookmarkFactory extends Factory
{
protected $model = Bookmark::class;

public function definition(): array
{
return [
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),

'post_id' => Post::factory(),
'user_id' => User::factory(),
];
}
}
22 changes: 22 additions & 0 deletions database/migrations/2026_01_09_200634_create_bookmarks_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

return new class extends Migration {
public function up(): void
{
Schema::create('bookmarks', function (Blueprint $table) {
$table->id();
$table->foreignId('post_id');
$table->foreignId('user_id');
$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('bookmarks');
}
};