I look for to make two interface
- Administrator (Administrator role)
- Subscriber (subscriber role)
I used for now auth and entrust (Github Link) of Laravel 4
A recording User
in my SubscriptionContoller.php I make this :
public function doRegister(){
$password=Input::get('password');
$data = array(
'email' => Input::get('email'),
'password' => Hash::make($password)
);
$rules = array(
'email' => 'required|email',
'password' => 'required'
);
$messages = array(
'required' => 'The :attribute field is required.',
);
$validator = Validator::make($data, $rules, $messages);
if ($validator->fails()) {
Session::flash('message', 'This email is already registered, please choose another one.');
return Redirect::to('subscription/register')
->withErrors($validator);
} else {
$user = new User;
$role = Role::where('name','=','agency')->first();
$user->email = Input::get('email');
$user->password = Hash::make($password);
$user->save();
$user->roles()->attach($role);
Session::flash('message', 'Successfully created account! Please login to submit your ad.');
return Redirect::to('subscription/dashbord');
}
}
How should i write the routes.php and filters.php ??