[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: NotificationController.php
<?php namespace App\Http\Controllers\Admin; use App\CentralLogics\Helpers; use App\Http\Controllers\Controller; use App\Models\Notification; use Brian2694\Toastr\Facades\Toastr; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Carbon\Carbon; use Illuminate\Support\Facades\Validator; class NotificationController extends Controller { function index() { $notifications = Notification::latest()->paginate(config('default_pagination')); return view('admin-views.notification.index', compact('notifications')); } public function store(Request $request) { $validator = Validator::make($request->all(), [ 'notification_title' => 'required', 'description' => 'required', 'tergat' => 'required', 'zone'=>'required' ], [ 'notification_title.required' => 'Title is required!', ]); if ($validator->fails()) { return response()->json(['errors' => Helpers::error_processor($validator)]); } if ($request->has('image')) { $image_name = Helpers::upload('notification/', 'png', $request->file('image')); } else { $image_name = null; } $notification = new Notification; $notification->title = $request->notification_title; $notification->description = $request->description; $notification->image = $image_name; $notification->tergat= $request->tergat; $notification->status = 1; $notification->zone_id = $request->zone=='all'?null:$request->zone; $notification->save(); $topic_all_zone=[ 'customer'=>'all_zone_customer', 'deliveryman'=>'all_zone_delivery_man', 'restaurant'=>'all_zone_restaurant', ]; $topic_zone_wise=[ 'customer'=>'zone_'.$request->zone.'_customer', 'deliveryman'=>'zone_'.$request->zone.'_delivery_man', 'restaurant'=>'zone_'.$request->zone.'_restaurant', ]; $topic = $request->zone == 'all'?$topic_all_zone[$request->tergat]:$topic_zone_wise[$request->tergat]; if($request->has('image')) { $notification->image = url('/').'/storage/app/public/notification/'.$image_name; } try { Helpers::send_push_notif_to_topic($notification, $topic, 'general'); } catch (\Exception $e) { Toastr::warning(trans('messages.push_notification_faild')); } return response()->json([], 200); } public function edit($id) { $notification = Notification::find($id); return view('admin-views.notification.edit', compact('notification')); } public function update(Request $request, $id) { $request->validate([ 'notification_title' => 'required', 'description' => 'required', 'tergat' => 'required', ], [ 'title.required' => 'title is required!', ]); $notification = Notification::find($id); if ($request->has('image')) { $image_name = Helpers::update('notification/', $notification->image, 'png', $request->file('image')); } else { $image_name = $notification['image']; } $notification->title = $request->notification_title; $notification->description = $request->description; $notification->image = $image_name; $notification->tergat= $request->tergat; $notification->zone_id = $request->zone=='all'?null:$request->zone; $notification->save(); $topic_all_zone=[ 'customer'=>'all_zone_customer', 'deliveryman'=>'all_zone_delivery_man', 'restaurant'=>'all_zone_restaurant', ]; $topic_zone_wise=[ 'customer'=>'zone_'.$request->zone.'_customer', 'deliveryman'=>'zone_'.$request->zone.'_delivery_man', 'restaurant'=>'zone_'.$request->zone.'_restaurant', ]; $topic = $request->zone == 'all'?$topic_all_zone[$request->tergat]:$topic_zone_wise[$request->tergat]; if($request->has('image')) { $notification->image = url('/').'/storage/app/public/notification/'.$image_name; } try { Helpers::send_push_notif_to_topic($notification, $topic, 'general'); } catch (\Exception $e) { Toastr::warning(trans('messages.push_notification_faild')); } Toastr::success(trans('messages.notification').' '.trans('messages.updated_successfully')); return back(); } public function status(Request $request) { $notification = Notification::find($request->id); $notification->status = $request->status; $notification->save(); Toastr::success(trans('messages.notification_status_updated')); return back(); } public function delete(Request $request) { $notification = Notification::find($request->id); if (Storage::disk('public')->exists('notification/' . $notification['image'])) { Storage::disk('public')->delete('notification/' . $notification['image']); } $notification->delete(); Toastr::success(trans('messages.notification_deleted_successfully')); return back(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium166.web-hosting.com
Server IP: 162.0.209.40
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium166.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 75.11 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kataubyb
User ID (UID): 624
Group ID (GID): 625
Script Owner UID: 624
Current Dir Owner: 624