notifications.stub
TLDR
The provided file is a migration file that creates a table for notifications in a database. It contains a class that extends Illuminate\Database\Migrations\Migration
and has two methods: up()
and down()
. The up()
method creates the notifications
table with specific columns, while the down()
method drops the notifications
table in case of a rollback.
Classes
Anonymous Class
This anonymous class extends Illuminate\Database\Migrations\Migration
and represents a migration for creating the notifications
table in the database. It contains the following methods:
-
up()
: This method is responsible for creating thenotifications
table using theSchema
facade. It defines the schema of the table, including columns forid
,type
,notifiable
,data
,read_at
, and timestamps. -
down()
: This method is responsible for dropping thenotifications
table using theSchema
facade in case of a rollback.
<?php
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('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};