mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
Update UI and migration,seeder for notification.
This commit is contained in:
@@ -3,8 +3,56 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Auth;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
return Notification::all();
|
||||
}
|
||||
|
||||
public function show(Notification $notification)
|
||||
{
|
||||
return $notification;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$notification = Notification::create($request->all());
|
||||
|
||||
return response()->json($notification, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Notification $notification)
|
||||
{
|
||||
$notification->update($request->all());
|
||||
|
||||
return response()->json($notification, 200);
|
||||
}
|
||||
|
||||
public function delete(Notification $notification)
|
||||
{
|
||||
$notification->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
public function getUserMessage()
|
||||
{
|
||||
return response()->json([
|
||||
"message" =>Notification::Where("user_id",Auth::user()->id)->get(),
|
||||
"unread_message" =>Notification::Where([
|
||||
["user_id",Auth::user()->id],
|
||||
["is_read",0]
|
||||
])->get()
|
||||
],200);
|
||||
}
|
||||
|
||||
public function readNotification(){
|
||||
$affected = DB::table('notifications')->Where('user_id', Auth::user()->id)->update(array('is_read' => 1));
|
||||
return response()->json("Read all message", 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user