NotificationsController.php (1181B)
1 <?php 2 3 namespace App\Http\Controllers; 4 5 use App\Http\Controllers\Controller; 6 use Mastodon; 7 use Illuminate\Http\Request; 8 9 use App\Helpers\Links; 10 use App\Helpers\PaginationParameters; 11 12 /** 13 * Controller for the notifications page. 14 */ 15 class NotificationsController extends Controller 16 { 17 /** 18 * Get and display notifications. 19 * 20 * @param Request $request The request containing pagination parameters. 21 * 22 * @return Illuminate\View\View The notifications page. 23 */ 24 public function get_notifications(Request $request) 25 { 26 $user = session('user'); 27 $params = (new PaginationParameters($request)) 28 ->to_array(); 29 30 # Fetch notifications from the API. 31 $notifications = Mastodon::domain(env('MASTODON_DOMAIN')) 32 ->token($user->token) 33 ->get('/notifications', $params); 34 35 $vars = [ 36 'notifications' => $notifications, 37 'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1], 38 'links' => new Links( 39 Mastodon::getResponse()->getHeader('link'), 40 'notifications' 41 ) 42 ]; 43 44 return view('notifications', $vars); 45 } 46 }