dimanche 13 octobre 2019

How to add custom event to a Laravel model

I have payment model and want to fire an custom event when payment confirmed.

My model code:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Payment extends Model
{
    protected $dates = [
        'created_at', 'updated_at', 'confirmed_at',
    ];

    public function confirmed(){
        $this->setAttribute('confirmed_at', now());
        $this->setAttribute('status', 'confirmed');
    }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/319QZYW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire