Current File : /home/tradevaly/www/app/Http/Controllers/Admin/NotificationController.php
<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\AdminNotification;
class NotificationController extends Controller
{
    public function index()
    {
        $notifications = AdminNotification::where('admin_reciver',"yes")->where('admin_del',"no")->latest()->paginate(50)->all();
        return view('backend.pages.notification.index',compact('notifications'));
    }
    public function delete($id)
    {
        $notification = AdminNotification::where('admin_reciver',"yes")->where('id',$id)->firstOrFail();
        if($notification->user_del == 'yes')
        {
           $notification->delete(); 
        }else{
        $notification->admin_del = "yes";
        $notification->save();
        }
        return back();
    }
}