style updates
This commit is contained in:
@@ -1,4 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Api\Models;
|
||||
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
final class Webhook extends Model {protected $fillable=['site_id','name','url','secret','events','is_active','failure_count','last_triggered_at'];protected $hidden=['secret'];protected function casts(): array{return ['events'=>'array','is_active'=>'boolean','last_triggered_at'=>'datetime'];}public function deliveries(): HasMany{return $this->hasMany(WebhookDelivery::class);}public function subscribesTo(string $event): bool{return in_array('*',$this->events?:[],true)||in_array($event,$this->events?:[],true);}}
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Webhook extends Model
|
||||
{
|
||||
protected $fillable = ['site_id', 'name', 'url', 'secret', 'events', 'is_active', 'failure_count', 'last_triggered_at'];
|
||||
|
||||
protected $hidden = ['secret'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['events' => 'array', 'is_active' => 'boolean', 'last_triggered_at' => 'datetime'];
|
||||
}
|
||||
|
||||
public function deliveries(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebhookDelivery::class);
|
||||
}
|
||||
|
||||
public function subscribesTo(string $event): bool
|
||||
{
|
||||
return in_array('*', $this->events ?: [], true) || in_array($event, $this->events ?: [], true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user