<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Reminder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class RemindersController extends Controller
{
public function setReminder(Request $request): JsonResponse
{
$reminder = Reminder::where('show_id', $request->show_id)->where('push_token', $request->token)->first();
if (!$reminder) {
$reminder = Reminder::create([
'push_token' => $request->token,
'days' => $request->days,
'show_name' => $request->show_name,
'start_time' => $request->start_time,
'show_id' => $request->show_id,
]);
return success_api_processor($reminder, 'Reminder set successfully!', 200);
}
return success_api_processor([], 'Reminder already set', 300);
}
public function deleteReminder(Request $request): JsonResponse
{
$reminder = Reminder::where('show_id', $request->show_id)->where('push_token', $request->token)->first();
if ($reminder) {
$reminder->delete();
return success_api_processor([], 'Reminder deleted successfully!', 200);
}
return error_api_processor('Reminder not found!', 300, []);
}
}