Skip to content

Commit c11e262

Browse files
Merge pull request #6 from iutrace/feature/VET-3598-notificacion-de-template-rechaz
Feature/vet 3598 notificacion de template rechaz
2 parents 2d7ca8a + 581891d commit c11e262

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"illuminate/database": "^8.83",
1212
"illuminate/console": "^8.83",
1313
"illuminate/bus": "^8.83",
14-
"illuminate/queue": "^8.83"
14+
"illuminate/queue": "^8.83",
15+
"laravel/framework": "^8.83"
1516
},
1617
"autoload": {
1718
"psr-4": {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Events\WhatsappTemplate;
4+
5+
use Iutrace\Botmaker\Models\WhatsappTemplate;
6+
use Illuminate\Foundation\Events\Dispatchable;
7+
8+
class Created
9+
{
10+
use Dispatchable;
11+
12+
public $whatsappTemplate;
13+
14+
/**
15+
* Crea una nueva instancia del evento.
16+
*
17+
* @param WhatsappTemplate $whatsappTemplate
18+
* @return void
19+
*/
20+
public function __construct(WhatsappTemplate $whatsappTemplate)
21+
{
22+
$this->whatsappTemplate = $whatsappTemplate;
23+
}
24+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Events\WhatsappTemplate;
4+
5+
use Iutrace\Botmaker\Models\WhatsappTemplate;
6+
use Illuminate\Foundation\Events\Dispatchable;
7+
8+
class Deleted
9+
{
10+
use Dispatchable;
11+
12+
public $whatsappTemplate;
13+
14+
public function __construct(WhatsappTemplate $whatsappTemplate)
15+
{
16+
$this->whatsappTemplate = $whatsappTemplate;
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Events\WhatsappTemplate;
4+
5+
use Iutrace\Botmaker\Models\WhatsappTemplate;
6+
use Illuminate\Foundation\Events\Dispatchable;
7+
8+
class Updated
9+
{
10+
use Dispatchable;
11+
12+
public $whatsappTemplate;
13+
14+
public function __construct(WhatsappTemplate $whatsappTemplate)
15+
{
16+
$this->whatsappTemplate = $whatsappTemplate;
17+
}
18+
}

src/Models/WhatsappTemplate.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Iutrace\Botmaker\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Support\Facades\Event;
67

78
class WhatsappTemplate extends Model
89
{
@@ -27,4 +28,27 @@ public function model()
2728
{
2829
return $this->morphTo();
2930
}
31+
32+
/**
33+
* The "boot" method of the model.
34+
*
35+
* @return void
36+
*/
37+
protected static function boot()
38+
{
39+
parent::boot();
40+
41+
static::created(function ($whatsappTemplate) {
42+
Event::dispatch(new \App\Events\WhatsappTemplate\Created($whatsappTemplate));
43+
});
44+
45+
static::updated(function ($whatsappTemplate) {
46+
Event::dispatch(new \App\Events\WhatsappTemplate\Updated($whatsappTemplate));
47+
});
48+
49+
static::deleted(function ($whatsappTemplate) {
50+
Event::dispatch(new \App\Events\WhatsappTemplate\Deleted($whatsappTemplate));
51+
});
52+
53+
}
3054
}

0 commit comments

Comments
 (0)