Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppHttpControllers;
- use AppUser;
- use AppBook;
- use AppReview;
- use AppComment;
- use IlluminateHttpRequest;
- use IlluminateSupportFacadesGate;
- class AdminsController extends Controller
- {
- public function admin()
- {
- if (Gate::allows('admins', auth()->user())) {
- return view('admin.dashboard');
- }
- return 'Unauthorized entry';
- }
- /**
- * Display a listing of the resource.
- *
- * @return IlluminateHttpResponse
- */
- public function index()
- {
- $users = User::all();
- $books = Book::all();
- $reviews = Review::all();
- $comments = Comment::all();
- return view('admin.dashboard', compact('users' ,'books', 'reviews', 'comments'));
- }
- Gate::define('admins', function ($user) {
- if($user->isAdmin == 1)
- {
- return true;
- }
- return false;
- });
- // Admin
- Route::resource('admin', 'AdminsController');
- Route::get('/admin', 'AdminsController@admin')->name('admin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement