diff --git a/app/Models/Article.php b/app/Models/Article.php new file mode 100644 index 0000000..928563b --- /dev/null +++ b/app/Models/Article.php @@ -0,0 +1,34 @@ +belongsTo(Author::class); + } +} diff --git a/app/Models/Author.php b/app/Models/Author.php new file mode 100644 index 0000000..a7971b0 --- /dev/null +++ b/app/Models/Author.php @@ -0,0 +1,39 @@ +hasOne(User::class); + } + + /** All the Articles this person has written */ + public function articles(): HasMany + { + return $this->hasMany(Article::class); + } +} diff --git a/database/migrations/2024_02_05_014414_create_articles_table.php b/database/migrations/2024_02_05_014414_create_articles_table.php new file mode 100644 index 0000000..4c77c9b --- /dev/null +++ b/database/migrations/2024_02_05_014414_create_articles_table.php @@ -0,0 +1,58 @@ +id(); + + $table->string('title', 255); + + // The URL-encoded version of the title, more or less. Also acts as + // the unique, public-facing identifier for the article + $table->string('slug', 255); + + $table->foreignId('author_id') + ->constrained(table: 'authors', indexName: 'articles_authors_id') + ->onUpdate('cascade') + ->onDelete('cascade'); + + $table->string('subtitle', 255)->nullable(); + + // The HTML-formatted version of the body, ready for browser display + $table->longText('body'); + + // The dateTime when the article was made public to the world. If + // it's in the future or doesn't exist, the article hasn't been + // published yet + $table->dateTime('published_at')->nullable(); + + $table->string('header_image_url', 255)->nullable(); + + // The path on the server disk to the original markdown file. + $table->string('path_to_markdown_source'); + + // The dateTime when the original markdown file was parsed and the + // HTML body was generated (among other things) + $table->dateTime('processed_at')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('articles'); + } +}; diff --git a/database/migrations/2024_02_05_014822_create_authors_table.php b/database/migrations/2024_02_05_014822_create_authors_table.php new file mode 100644 index 0000000..44b17c1 --- /dev/null +++ b/database/migrations/2024_02_05_014822_create_authors_table.php @@ -0,0 +1,51 @@ +id(); + + // Since we're separating authors and Word Salad User's as entities, this will strictly control how their + // name appears in authorial contexts. + $table->string('display_name', 100); + + // The link the author's profile picture + $table->string('profile_image_url')->nullable(); + + $table->foreignId('user_id') + ->constrained(table: 'users', indexName: 'authors_user_id') + ->onUpdate('cascade') + ->onDelete('cascade') + ->nullable(); + + // An introductory paragraph or two of the author + $table->text('biography')->nullable(); + + // A URL to the author's primary home on the web, a special shout out, whatever + $table->string('primary_link', 120)->nullable(); + $table->string('secondary_link', 120)->nullable(); + + $table->string('mastodon_handle', 200)->nullable(); + + // created_at and updated_at timestamps + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('authors'); + } +};