Generate article publications
This commit is contained in:
parent
8aaf614fe7
commit
137cb4ebfc
2 changed files with 59 additions and 0 deletions
29
app/Models/ArticlePublication.php
Normal file
29
app/Models/ArticlePublication.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class ArticlePublication extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'article_id',
|
||||||
|
'published_at',
|
||||||
|
'community_id',
|
||||||
|
'published_by',
|
||||||
|
'post_id',
|
||||||
|
'platform',
|
||||||
|
'publication_data',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'published_at' => 'datetime',
|
||||||
|
'publication_data' => 'array',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function article(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Article::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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('article_publications', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('article_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('post_id');
|
||||||
|
$table->unsignedBigInteger('community_id');
|
||||||
|
$table->string('platform')->default('lemmy');
|
||||||
|
$table->json('publication_data')->nullable();
|
||||||
|
$table->timestamp('published_at');
|
||||||
|
$table->string('published_by');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['article_id', 'platform', 'community_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('article_publications');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue