403Webshell
Server IP : 66.29.132.124  /  Your IP : 3.147.49.19
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/book24.ng/modules/Core/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/book24.ng/modules/Core/Controllers/NotificationController.php
<?php
/**
 * Created by PhpStorm.
 * User: h2 gaming
 * Date: 8/13/2019
 * Time: 10:19 PM
 */
namespace Modules\Core\Controllers;

use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Modules\Core\Models\Notification;
use Modules\Core\Models\NotificationPush;

class NotificationController extends Controller
{
    public function markRead(Request $request){
        $ids = $request->input('ids');
        if(!empty($ids) and is_array($ids))
        {
            Notification::query()->whereIn('id',$ids)->where('to_user',Auth::id())->update([
                'is_read'=>1
            ]);
        }
    }

    public function markAsRead(Request $request){
        $id = $request->get('id');
        if(!empty($id))
        {
            NotificationPush::query()->where('id', $id)->update([
                'read_at' => now()
            ]);
        }
        return response()->json([], 200);
    }

    public function markAllAsRead(Request $request){
        $notify = NotificationPush::query();
        if(is_admin()){
            $notify->where(function($q){
                $q->where('data', 'LIKE', '%"for_admin":1%');
                $q->orWhere('notifiable_id', Auth::id());
            });
        }else{
            $notify->where('data', 'LIKE', '%"for_admin":0%');
            $notify->where('notifiable_id', Auth::id());
        }
        $notify->where('read_at', null)
            ->update([
                'read_at' => now()
            ]);
        return response()->json([], 200);
    }

    public function loadNotify(Request $request)
    {
        $type = $request->get('type', '');
        $query  = \Modules\Core\Models\NotificationPush::query();

        if(is_admin()){
            $query->where(function($q){
                $q->where('data', 'LIKE', '%"for_admin":1%');
                $q->orWhere('notifiable_id', Auth::id());
            });
        }else{
            $query->where('data', 'LIKE', '%"for_admin":0%');
            $query->where('notifiable_id', Auth::id());
        }

        if($type == 'unread'){
            $query->where('read_at', null);
        }

        if($type == 'read'){
            $query->where('read_at', '!=', null);
        }

        $query->orderBy('created_at','desc');
        $data = [
            'rows'                  => $query->paginate(20),
            'page_title'            => __("All Notifications"),
            'type'                  => $type
        ];
        return view('Core::frontend.notification.index', $data);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit