save to codehub
This commit is contained in:
41
app/Http/Controllers/Admin/ManageNotificationController.php
Normal file
41
app/Http/Controllers/Admin/ManageNotificationController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user