java tutorials and useful tips for developer.

Monday, 3 February 2020

Notifications Migration for LUMEN

Create a migration file with this command: php artisan make:migration app-notifications

Next open that file in any editor and paste this code:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotificationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        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.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('notifications');
    }
}


Now run php artisan migrate and you are good to save notifications in DB.

Categories

Popular Posts

Live Stats

Powered by Blogger.