refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
43
app/Services/Contact/Reminder/DestroyReminder.php
Normal file
43
app/Services/Contact/Reminder/DestroyReminder.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Contact\Reminder;
|
||||
|
||||
use App\Services\BaseService;
|
||||
use App\Models\Contact\Reminder;
|
||||
|
||||
class DestroyReminder extends BaseService
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the service.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'account_id' => 'required|integer|exists:accounts,id',
|
||||
'reminder_id' => 'required|integer|exists:reminders,id',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a reminder and all scheduled reminders that are associated with
|
||||
* it (in ReminderOutbox table) thanks to foreign keys.
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function execute(array $data): bool
|
||||
{
|
||||
$this->validate($data);
|
||||
|
||||
$reminder = Reminder::where('account_id', $data['account_id'])
|
||||
->findOrFail($data['reminder_id']);
|
||||
|
||||
$reminder->contact->throwInactive();
|
||||
|
||||
$reminder->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user