Files
RelaisSMS/app/Http/Controllers/CardDavSyncController.php
T

26 lines
721 B
PHP

<?php
namespace App\Http\Controllers;
use App\Services\CardDav\CardDavContactSyncService;
use Illuminate\Http\RedirectResponse;
use Throwable;
class CardDavSyncController extends Controller
{
public function __invoke(CardDavContactSyncService $syncService): RedirectResponse
{
try {
$run = $syncService->sync();
} catch (Throwable $exception) {
return redirect()
->route('contacts.index')
->with('status', 'Synchronisation CardDAV en echec : '.$exception->getMessage());
}
return redirect()
->route('contacts.index')
->with('status', $run->message ?? 'Synchronisation CardDAV terminee.');
}
}