# fluent-boards/1.13/app/Models/Webhook.php

FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration, version 1.13. 71 lines.

- Page: https://pluginprobe.com/plugins/fluent-boards/1.13/code/app/Models/Webhook.php
- Raw: https://pluginprobe.com/plugins/fluent-boards/1.13/raw/app/Models/Webhook.php
- Modified: 2024-05-31T06:41:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-boards/1.13/code/app/Models/Webhook.php#L10-L20`.

```php
<?php

namespace FluentBoards\App\Models;

class Webhook extends Meta
{
    protected $fillable = [
        'object_id',
        'object_type',
        'key',
        'value',
    ];

    public static function boot()
    {
        parent::boot();

        static::addGlobalScope('type', function ($builder) {
            $builder->where('object_type', '=', 'webhook');
        });
    }

    public function getFields()
    {
        $taskFields = [
            'fields' => [],
        ];

        foreach (Task::mappableFields() as $key => $column) {
            $taskFields['fields'][] = ['key' => $key, 'field' => $column];
        }

        return $taskFields;
    }

    public function getSchema()
    {
        $schema = [
            'name'      => '',
            'url'       => '',
        ];

        return $schema;
    }

    public function store($data)
    {
        return static::create([
            'object_type' => 'webhook',
            'key' => $key = wp_generate_uuid4(),
            'value' => array_merge($data, [
                'url' => site_url("?fbs=1&route=task&hash={$key}")
            ]),
        ]);
    }

    public function saveChanges($data)
    {
        $this->value = array_merge(
            $this->value,
            array_diff_key($data, [
                'id' => '', 'url' => ''
            ])
        );

        $this->save();

        return $this;
    }
}

```
