반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- auth
- Laravel
- 체당금
- Java
- 홈택스
- Blade
- Tutorial
- Eclipse
- php
- win32
- 인민공원
- reactnative
- elasticSearch
- 코로나
- as후기
- cartalyst
- 전자소송
- 소액임금체불
- Bootstrap
- 이더리움
- 당사자표시정정신청서
- vue
- 사업자계좌
- 보정명령
- javascript
- blockchain
- 개인사업자
- Sentinel
- 코로나19
- Python
Archives
- Today
- Total
그냥 사는 이야기
Laravel 5.3 Sentinel - Roles 본문
반응형
roles 데이터 추가
Sentinel로 구성된 db에는 roles 라는 테이블이 존재한다. 여기에 2개의 data를 insert 하는데 slug, name column에
- admin, Admin
- manager, Manager
이렇게 2개의 data를 insert 한다.
role 부여
user를 register 할 때 이전 단계에서 생성했던 role중 manager role을 주는 방법은
RegistrationController
public function postRegister(Request $request)
{
$user = Sentinel::registerAndActivate($request->all());
$role = Sentinel::findRoleBySlug('manager'); // 추가
$role->users()->attach($user); // 추가
return redirect('/');
}
이렇게 한 후 user를 가입시켜 보면 role_users 테이블에 user_id와 role_id가 추가된 것을 확인할 수 있다.
'Development > Web' 카테고리의 다른 글
Laravel 5.3 Sentinel - Visitors & Manager (0) | 2020.01.21 |
---|---|
Laravel 5.3 Sentinel - Restricting Access According to Roles (0) | 2020.01.21 |
Laravel 5.3 Sentinel - Logout & show content to logged users only (0) | 2020.01.21 |
Laravel 5.3 Sentinel - Menu (0) | 2020.01.21 |
Laravel 5.3 Sentinel - Login (0) | 2020.01.21 |
Comments