E
E
Eduard Bazhenov2019-08-18 18:25:16
Laravel
Eduard Bazhenov, 2019-08-18 18:25:16

How to separate an application into an admin part and a user account?

The site will have an admin part with the path /admin/ and a user account /cabinet/. It is necessary that the admin can see only his part, and the user only his. I divided the controllers into directories. There is an idea to make two middlewares and put them on groups of routes. Am I right, or is there another way to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2019-08-18
@kip_34

Am I thinking right
Yes.

O
organica, 2019-08-20
@organica

I made this a little crutch, but maybe it will do for you:
In the template

@if(Auth::check())
    @if(Auth::user()->admin == 1)
%контент, отображаемый для администратора%
    @endif
%контент, отображаемый для рядового юзера%
@endif

For the user table, add the admin column, assign one to your account

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question