41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\NewsStatus;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('news', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignIdFor(User::class, 'author_id');
|
|
$table->string('title', 200);
|
|
$table->string('slug', 200);
|
|
$table->text('content');
|
|
$table->text('excerpt');
|
|
$table->string('link', 50)->nullable();
|
|
$table->unsignedInteger('views')->default(0);
|
|
$table->enum('status', [NewsStatus::values()])->comment(NewsStatus::comment());
|
|
$table->timestamp('published_at')->nullable();
|
|
$table->timestamp('created_at')->useCurrent();
|
|
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
|
$table->softDeletes();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('news');
|
|
}
|
|
};
|