PATH:
home
/
rwabteecom
/
project_11
/
app
/
Http
/
Controllers
/
Admin
/
Notification
/
Editing: NotificationController.php
<?php namespace App\Http\Controllers\Admin\Notification; use App\Datatables\NotificationDatatables; use App\Http\Controllers\Controller; use App\Services\Notification\NotificationServices; use Auth; use Exception; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Throwable; class NotificationController extends Controller { public function __construct(private readonly NotificationDatatables $notificationDatatables, private readonly NotificationServices $notificationServices) { } public function index(Request $request) { if ($request->expectsJson()) { return $this->notificationDatatables->datatables($request); } return view("admin.pages.notifications.index")->with([ "column" => $this->notificationDatatables::columns() ]); } public function show($id) { $notification = $this->notificationServices->markAsRead($id); return redirect()->away($notification->data["url"]); } public function ajax() { return view('global.notifications'); } public function markAllAsRead() { try { $this->notificationServices->markAllAsRead(); } catch (Exception|Throwable $exception) { Log::error($exception->getMessage()); return back()->with("error", $exception->getMessage()); } return back()->with("success", __("All Notifications Marked As Read")); } public function destroy($id) { try { $this->notificationServices->destroy($id); } catch (Exception|Throwable $exception) { Log::error($exception->getMessage()); return back()->with("error", $exception->getMessage()); } return back()->with('success', __("Notification Deleted Successfully")); } public function destroyAll() { try { $this->notificationServices->destroyAll(); } catch (Exception|Throwable $exception) { Log::error($exception->getMessage()); return back()->with("error", $exception->getMessage()); } return back()->with("success", __("All Notification Deleted Successfully")); } }
SAVE
CANCEL