H
H
HeartOfProgrammer2016-05-08 13:33:14
Laravel
HeartOfProgrammer, 2016-05-08 13:33:14

How to make Auth::check() && login == 'HeartProgrammer'?

I am building an online sporting goods store. It is necessary to make sure that the "Edit" and "Delete" buttons are only available to one user - "Administrator".
It is necessary that the conditions are compared with the user by login or by boolean type.
I don't know how to do this in laravel.
So far my code is like this:

@if(Auth::check())
<p><a href="#" class="btn btn-success" role="button">Редактировать</a> <a href="#" class="btn btn-danger" role="button">Удалить</a></p>
@endif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Pochepko, 2016-05-08
@HeartOfProgrammer

You need to make roles and accesses in the application. It will be more correct.
Look towards the Entrust
or
Sentinel
package . The first one works on standard authentication, and the second one works with its own. We'll have to change the structure a bit.
And as a last resort

@if(Auth::check() && (Auth::user()->is_admin)
<p><a href="#" class="btn btn-success" role="button">Редактировать</a> <a href="#" class="btn btn-danger" role="button">Удалить</a></p>
@endif

And in the database, enter the boolean field is_admin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question