Im新的Cartalyst哨兵和ACL的概念。我設法創建了一個用戶,執行激活和登錄並註銷。Cartalyst Sentinel Laravel - 你如何創建角色?
我想把我的學習提升到一個新的水平。我希望這個laravel應用程序有兩種類型的用戶。 1是管理員另一個是訂閱者。我假設我的帳戶創建方法應默認情況下爲用戶創建一個訂戶。
public function postCreate() {
/* Validation */
$validation = Validator::make(Input::all(), [
'email' => 'required|email|max:50|unique:users',
'username' => 'required|min:3|max:20|unique:users',
'password' => 'required|min:6',
'password_repeat' => 'required|same:password',
]);
if ($validation->fails()) {
return Redirect('login')->withErrors($validation)->withInput();
} else {
$credentials = Input::all();
$user = Sentinel::register($credentials);
$activation = Activation::create($user);
$activation_code = $activation->code;
if ($user) {
Mail::send('emails.auth.activate', ['link' => URL::route('account-activate', [$user->id, $activation_code]), 'username' => $user->username], function($message) use ($user) {
$message->to($user->email, $user->username)->subject('Activate your account');
});
return Redirect::route('home')->with('global', 'Thank you for registering! We have sent you an email to activate your account');
}
}
}
我是否改變,像這樣
$user = Sentinel::register($credentials);
$user = Sentinel::findById(1);
$role = Sentinel::findRoleByName('Subscribers');
$role->users()->attach($user);
事情是我還沒有創建任何角色開始與代碼。我們在哪裏編寫該功能?現在,我有以下控制器
- 的AccountController - 處理激活的
- AuthController - 處理登錄/退出
- 這個RegistrationController - 處理的用戶註冊
- RolesController - 我不是這裏面寫的任何東西。我有點失落。
請指導我。任何幫助是極大的讚賞。
我有同樣的問題。任何幫助是極大的讚賞。 – Michael 2014-10-04 23:38:01