반응형
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 | 29 | 30 |
Tags
- 개인사업자
- reactnative
- php
- as후기
- auth
- Python
- Java
- blockchain
- 전자소송
- 코로나19
- Bootstrap
- Sentinel
- win32
- 체당금
- elasticSearch
- vue
- 보정명령
- javascript
- 홈택스
- Blade
- 이더리움
- 코로나
- Eclipse
- cartalyst
- 당사자표시정정신청서
- 소액임금체불
- Laravel
- 사업자계좌
- Tutorial
- 인민공원
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 |