42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\User;
|
|
use App\Models\NotificationMaster;
|
|
use App\Models\NotificationUser;
|
|
|
|
class ManageNotificationController extends Controller
|
|
{
|
|
public function create(){
|
|
return view('Admin.Pages.manage_notification.manage_notification');
|
|
}
|
|
|
|
public function send_notification(Request $request){
|
|
|
|
// print_r($request->all());
|
|
// exit;
|
|
$user = User::get();
|
|
|
|
// NotificationMaster::create[]
|
|
$notification_master = new NotificationMaster;
|
|
$notification_master->title = $request->title;
|
|
$notification_master->messages = $request->message;
|
|
$notification_master->save();
|
|
|
|
$notification_id = $notification_master->id;
|
|
|
|
foreach ($user as $user_data){
|
|
|
|
$notification_user = new NotificationUser;
|
|
$notification_user->notification_id = $notification_id;
|
|
$notification_user->user_id = $user_data->id;
|
|
$notification_user->save();
|
|
}
|
|
|
|
return response()->json(['success' => true,'status' => 200]);
|
|
}
|
|
}
|