Ekapp/skolehjem/app/Http/Controllers/RootController.php

35 lines
895 B
PHP
Raw Normal View History

2020-06-08 13:08:46 +00:00
<?php
namespace App\Http\Controllers;
use App\News;
2020-06-08 13:08:46 +00:00
use Illuminate\Http\Request;
2020-06-24 06:23:15 +00:00
use Illuminate\Http\Response;
2020-06-08 13:08:46 +00:00
class RootController extends Controller
{
2020-06-30 08:42:10 +00:00
function __construct()
{
$this->middleware("auth");
2020-08-06 13:31:38 +00:00
$this->middleware([ "lang" ]);
2020-06-30 08:42:10 +00:00
}
2020-06-08 13:08:46 +00:00
public function index() {
$perPage = 2;
if(auth()->user()->can('admin.panel.show')) {
if(Response::detect("root.index")->name() == "admin.root.index")
return Response::detect("root.index");
else {
$news = News::query()->orderBy('id', 'asc')->paginate($perPage);
return Response::detect("root.index", ["news" => $news]);
}
}
else {
$news = News::query()->orderBy('id', 'asc')->paginate($perPage, ['*'], "page");
return view('app.root.index', ["news" => $news]);
}
2020-06-08 13:08:46 +00:00
}
}