qTylok
5 months ago
311
2
Laravel

Notification system

Posted 5 months ago by qTylok

Hi, I would like to know how I could send a notification to a user when he received a comment on his post? So far I have made the database but I do not know from here how to make and how to return a notification to the user in view or how to make the controller, an idea? Forget the comment database and notification database.

public function up()
    {
        Schema::create('post_comments', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('post_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->text('commentText');
            $table->boolean('check')->default(0);
            $table->string('name');
            $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->timestamps();
        });
    }

public function up()
    {
        Schema::create('notifications', function (Blueprint $table) {
            $table->increments('id');
            $table->string('type');
            $table->morphs('notifiable');
            $table->text('data');
            $table->timestamp('read_at')->nullable();
            $table->timestamps();
        });
    }

How can I in the controller to send notifications in view? I just want an idea.

Please sign in or create an account to participate in this conversation.