This commit is contained in:
sayliraut
2024-06-18 12:46:04 +05:30
parent 1c44067385
commit 963783ba28
5 changed files with 115 additions and 56 deletions

View File

@@ -9,6 +9,7 @@ use Illuminate\Http\Request;
use Exception;
use Illuminate\Support\Facades\Log;
use App\Helpers\onesignalhelper;
use App\Models\ManageState;
use Illuminate\Support\Facades\DB;
class ManageNotificationsController extends Controller
@@ -70,7 +71,8 @@ class ManageNotificationsController extends Controller
*/
public function add()
{
return view('Admin.pages.manage_notification.manage_notifications_add');
$state = ManageState::where('is_active', 1)->get()->toArray();
return view('Admin.pages.manage_notification.manage_notifications_add', compact('state'));
}
/**
@@ -80,6 +82,7 @@ class ManageNotificationsController extends Controller
*/
public function store_notificaton_data(Request $request)
{
dd($request);
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
@@ -103,10 +106,12 @@ class ManageNotificationsController extends Controller
$allCustomerOneSignalIds = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->where('state_xid', $request->state)
->pluck('id');
$allRestaurantOneSignalIds = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 4)
->where('principal_type_xid', 3)
->where('state_xid', $request->state)
->pluck('id');
@@ -118,7 +123,7 @@ class ManageNotificationsController extends Controller
$imageUrl = $imagePath;
// FOR all customer
if ($request->recipients == 'customer') {
if ($request->user_type == 1) {
foreach ($UserData as $customerIdItem) {
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
@@ -132,7 +137,7 @@ class ManageNotificationsController extends Controller
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
}
} elseif ($request->recipients == 'restaurant') {
} elseif ($request->user_type == 2) {
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
foreach ($restaurantData as $restIdItem) {
@@ -171,5 +176,4 @@ class ManageNotificationsController extends Controller
$notification = NotificationDetails::with('notification')->findOrFail($id);
return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification'));
}
}