Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $validator = Validator::make($this->request->all(), [
- 'role' => array('required', 'in:'.implode(',' , array_keys($this->roles))),
- 'username' => array('required', 'unique:admins,username', 'min:3'),
- 'password' => array('required', 'min:6'),
- 'email' => array('required', 'email', 'unique:admins,email'),
- ]);
- if ($validator->fails()) {
- return redirect('admins/add/'.$role)
- ->withInput()
- ->withErrors($validator);
- } else {
- if(in_array($this->request->input('role'), $this->allowed_roles[Auth::guard('admin')->user()->role])) {
- $item = new Admin;
- $item->role = $this->request->input('role');
- $item->username = $this->request->input('username');
- $item->password = bcrypt($this->request->input('password'));
- $item->email = $this->request->input('email');
- $item->comments = $this->request->input('comments');
- $item->phone = $this->request->input('phone');
- $item->company_name = $this->request->input('company_name');
- $item->vat = $this->request->input('vat');
- $item->discount = $this->request->input('discount');
- if( $this->request->input('role')=='employee' || $this->request->input('role')=='affiliate' ) {
- $item->manager_id = Auth::guard('admin')->user()->id;
- }
- if( $this->request->input('role')=='employee' ) {
- $item->hotel_id = Auth::guard('admin')->user()->hotel_id;
- }
- if( $this->request->input('role')=='manager' ) {
- $item->hotel_id = $this->request->input('hotel_id');
- }
- $item->save();
- if( Request::file('image') && Request::file('image')->isValid() ) {
- $img = Image::make( Input::file('image') )->orientate();
- $item->addImage($img);
- }
- }
- $this->request->session()->flash('success-message', 'Account created');
- return redirect('admins');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement