Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
membrubackend
/
app
/
Http
/
Controllers
/
Api
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
NotificationLogController.php
| Size :
3.25
KB
Copy
<?php namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Models\NotificationLog; use Auth; use Illuminate\Http\Request; class NotificationLogController extends Controller { public function index(Request $request) { $viewMore = $request->view_more; $authUser = Auth::user(); if($request->type && $request->type == 'activity'){ $notificationLogsActivity = $authUser->instance->notification_logs()->where('for_all', 1)->latest()->skip($viewMore)->take(20)->get(); $notificationLogsActivity = $notificationLogsActivity->map(function ($notificationLog){ $translationType = $notificationLog->for_auth_user ? null : 'public'; return [ 'id' => $notificationLog->id, 'name' => $notificationLog->getNotificationName($translationType), 'avatar' => $notificationLog->avatar, 'seen' => $notificationLog->seen, 'need_link' => $notificationLog->need_link, 'created_at' => $notificationLog->created_at, 'type' => $notificationLog->type, 'objective_slug'=> $notificationLog->objective_slug, 'key_result_id' => $notificationLog->key_result_id, 'frontend_type' => $notificationLog->frontend_type ]; }); }else{ $notificationLogs = $authUser->notification_logs()->where('for_auth_user', 1)->latest()->skip($viewMore)->take(20)->get(); $notificationLogs = $notificationLogs->map(function ($notificationLog){ $translationType = $notificationLog->for_auth_user ? null : 'public'; return [ 'id' => $notificationLog->id, 'name' => $notificationLog->getNotificationName($translationType), 'avatar' => $notificationLog->avatar, 'seen' => $notificationLog->seen, 'need_link' => $notificationLog->need_link, 'created_at' => $notificationLog->created_at, 'type' => $notificationLog->type, 'objective_slug'=> $notificationLog->objective_slug, 'key_result_id' => $notificationLog->key_result_id, 'frontend_type' => $notificationLog->frontend_type ]; }); $unreadNotifications = $authUser->notification_logs()->where([['for_auth_user', 1], ['seen', 0]])->count(); } return response()->json([ 'status' => 'success', 'data' => [ 'unread' => isset($notificationLogs) ? $notificationLogs : null, 'activity' => isset($notificationLogsActivity) ? $notificationLogsActivity : null, 'count_unread' => isset($unreadNotifications) ? $unreadNotifications : 0, ] ], 200); } public function update(NotificationLog $notificationLog) { $notificationLog->update(['seen' => 1]); return response()->json([ 'status' => 'success' ], 200); } }
Back