diff --git a/app/Console/Commands/ImportBookmarks.php b/app/Console/Commands/ImportBookmarks.php new file mode 100644 index 0000000..60eb6e7 --- /dev/null +++ b/app/Console/Commands/ImportBookmarks.php @@ -0,0 +1,64 @@ +href = $bookmark_json['href']; + $bookmark->title = $bookmark_json['description']; + $bookmark->description = $bookmark_json['extended']; + $bookmark->created_at = $created_at; + $bookmark->updated_at = $created_at; + $bookmark->save(); + + $tokens = explode(' ', $bookmark_json['tags']); + foreach ($tokens as $tag_raw) { + $tag = Tag::firstOrCreate( + [ + 'name' => $tag_raw, + ] + ); + + $bookmark_tag = new BookmarkTag; + $bookmark_tag->bookmark_id = $bookmark->id; + $bookmark_tag->tag_id = $tag->id; + $bookmark_tag->save(); + } + } + + DB::rollBack(); + } +} diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php new file mode 100644 index 0000000..9430084 --- /dev/null +++ b/app/Http/Controllers/BookmarkController.php @@ -0,0 +1,71 @@ + $bookmark = Bookmark::findOrFail($id), + 'tags' => $bookmark->children, + ] + ); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/Bookmark.php b/app/Models/Bookmark.php new file mode 100644 index 0000000..1723ceb --- /dev/null +++ b/app/Models/Bookmark.php @@ -0,0 +1,18 @@ +hasMany(BookmarkTag::class, 'bookmark_id'); + } +} diff --git a/app/Models/BookmarkTag.php b/app/Models/BookmarkTag.php new file mode 100644 index 0000000..7db9ab0 --- /dev/null +++ b/app/Models/BookmarkTag.php @@ -0,0 +1,24 @@ +belongsTo(Bookmark::class, 'bookmark_id'); + } + + public function tag(): HasOne + { + return $this->hasOne(Tag::class, 'id', 'tag_id'); + } +} diff --git a/app/Models/Tag.php b/app/Models/Tag.php new file mode 100644 index 0000000..6b7af87 --- /dev/null +++ b/app/Models/Tag.php @@ -0,0 +1,11 @@ +withMiddleware(function (Middleware $middleware) { - // - }) - ->withExceptions(function (Exceptions $exceptions) { - // - })->create(); + ->withMiddleware( + function (Middleware $middleware) { + // + } + ) + ->withExceptions( + function (Exceptions $exceptions) { + // + } + )->create(); diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php deleted file mode 100644 index 05fb5d9..0000000 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ /dev/null @@ -1,49 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - - Schema::create('sessions', function (Blueprint $table) { - $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); - $table->string('ip_address', 45)->nullable(); - $table->text('user_agent')->nullable(); - $table->longText('payload'); - $table->integer('last_activity')->index(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('users'); - Schema::dropIfExists('password_reset_tokens'); - Schema::dropIfExists('sessions'); - } -}; diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php deleted file mode 100644 index b9c106b..0000000 --- a/database/migrations/0001_01_01_000001_create_cache_table.php +++ /dev/null @@ -1,35 +0,0 @@ -string('key')->primary(); - $table->mediumText('value'); - $table->integer('expiration'); - }); - - Schema::create('cache_locks', function (Blueprint $table) { - $table->string('key')->primary(); - $table->string('owner'); - $table->integer('expiration'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache'); - Schema::dropIfExists('cache_locks'); - } -}; diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php deleted file mode 100644 index 425e705..0000000 --- a/database/migrations/0001_01_01_000002_create_jobs_table.php +++ /dev/null @@ -1,57 +0,0 @@ -id(); - $table->string('queue')->index(); - $table->longText('payload'); - $table->unsignedTinyInteger('attempts'); - $table->unsignedInteger('reserved_at')->nullable(); - $table->unsignedInteger('available_at'); - $table->unsignedInteger('created_at'); - }); - - Schema::create('job_batches', function (Blueprint $table) { - $table->string('id')->primary(); - $table->string('name'); - $table->integer('total_jobs'); - $table->integer('pending_jobs'); - $table->integer('failed_jobs'); - $table->longText('failed_job_ids'); - $table->mediumText('options')->nullable(); - $table->integer('cancelled_at')->nullable(); - $table->integer('created_at'); - $table->integer('finished_at')->nullable(); - }); - - Schema::create('failed_jobs', function (Blueprint $table) { - $table->id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('jobs'); - Schema::dropIfExists('job_batches'); - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/database/schema/sqlite-schema.sql b/database/schema/sqlite-schema.sql new file mode 100644 index 0000000..7cfac1a --- /dev/null +++ b/database/schema/sqlite-schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS "migrations" ("id" integer primary key autoincrement not null, "migration" varchar not null, "batch" integer not null); +CREATE TABLE IF NOT EXISTS "bookmarks" ("id" integer primary key autoincrement not null, "href" varchar not null, "title" varchar not null, "description" varchar not null, "created_at" datetime, "updated_at" datetime); +CREATE TABLE IF NOT EXISTS "tags" ("id" integer primary key autoincrement not null, "name" varchar not null, "created_at" datetime, "updated_at" datetime); +CREATE TABLE IF NOT EXISTS "bookmarks_tags" ("id" integer primary key autoincrement not null, "bookmark_id" integer not null, "tag_id" integer not null, "created_at" datetime, "updated_at" datetime, foreign key("bookmark_id") references "bookmarks"("id"), foreign key("tag_id") references "tags"("id")); +CREATE TABLE IF NOT EXISTS "sessions" ("id" varchar not null, "user_id" integer, "ip_address" varchar, "user_agent" text, "payload" text not null, "last_activity" integer not null, primary key ("id")); +CREATE INDEX "sessions_user_id_index" on "sessions" ("user_id"); +CREATE INDEX "sessions_last_activity_index" on "sessions" ("last_activity"); +INSERT INTO migrations VALUES(1,'2024_05_24_204027_create_tables',1); +INSERT INTO migrations VALUES(2,'2024_05_24_224743_create_sessions_table',2); diff --git a/resources/views/bookmark.blade.php b/resources/views/bookmark.blade.php new file mode 100644 index 0000000..f3178cb --- /dev/null +++ b/resources/views/bookmark.blade.php @@ -0,0 +1,11 @@ +