migrate to gtea from bistbucket
This commit is contained in:
56
app/Http/Controllers/Admin/NotificationController.php
Normal file
56
app/Http/Controllers/Admin/NotificationController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Notification;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('permission:notifications-read')->only('mtIndex');
|
||||
}
|
||||
|
||||
public function mtIndex()
|
||||
{
|
||||
$notifications = auth()->user()->notifications()
|
||||
->whereDate('created_at', today())
|
||||
->latest()
|
||||
->get();
|
||||
return view('admin.notifications.index', compact('notifications'));
|
||||
}
|
||||
|
||||
public function acnooFilter(Request $request)
|
||||
{
|
||||
$notifications = Notification::whereDate('created_at', today())->latest()->paginate($request->per_page ?? 20);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json([
|
||||
'data' => view('admin.notifications.datas', compact('notifications'))->render()
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect(url()->previous());
|
||||
}
|
||||
|
||||
public function mtView($id)
|
||||
{
|
||||
$notify = Notification::find($id);
|
||||
if ($notify) {
|
||||
$notify->read_at = now();
|
||||
$notify->save();
|
||||
return redirect($notify->data['url'] ?? '/');
|
||||
}
|
||||
|
||||
return back()->with('error', __('Premission denied.'));
|
||||
}
|
||||
|
||||
public function mtReadAll()
|
||||
{
|
||||
auth()->user()->unreadNotifications()->update(['read_at' => now()]);
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user