Ejemplo n.º 1
0
 /**
  * Show the user profile.
  *
  * @return Response
  */
 public function profile()
 {
     try {
         $user = User::with('groups')->findOrFail(Auth::user()->id);
         Debugbar::info($user->toArray());
         $user_form = \FormBuilder::create('Isabry\\Gatekeeper\\Forms\\UserForm', ['model' => $user])->remove('password')->remove('password_confirmation');
         return view('gatekeeper::home.profile')->with(compact('user_form'))->with('user', $user);
     } catch (ModelNotFoundException $e) {
         Session::flash('error', 'User not found (id: ' . $id . ')');
         return Redirect::intended('/');
     }
 }
Ejemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $class = $this->params['model'];
     $entry = $class::find($id);
     $form = \FormBuilder::create($this->params['form'], ['method' => 'PUT', 'model' => $entry, 'url' => route("{$this->params['route']}.update", [$id]), 'data' => $this->params['form_data']]);
     $tplPath = base_path('resources/views/' . $this->params['tpl_path']);
     if (is_dir($tplPath)) {
         $view = "{$this->params['tpl_path']}.edit";
     } else {
         $view = 'crud::entry.edit';
     }
     return view($view, compact('form'));
 }
Ejemplo n.º 3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $user = User::with('groups')->findOrFail($id);
         Debugbar::info($user->toArray());
         $user_form = \FormBuilder::create('Isabry\\Gatekeeper\\Forms\\UserForm', ['model' => $user])->remove('password')->remove('password_confirmation');
         $url = '<a role="button" href="' . route('users.index') . '" class="btn btn-primary">' . '  <i class="fa fa-mail-reply"></i> Back to Users List' . '</a>';
         return view('gatekeeper::users.view')->with('title', 'User (' . $user->name . ')')->with(compact('user_form'))->with('url', $url);
     } catch (ModelNotFoundException $e) {
         Session::flash('error', 'User not found (id: ' . $id . ')');
         return Redirect::intended('users');
     }
 }
Ejemplo n.º 4
0
 /**
  * Attributes name from field label
  *
  * @return [string]
  */
 public function attributes()
 {
     if ($this->form) {
         $attributes = [];
         $formFields = \FormBuilder::create($this->form)->getFields();
         foreach ($formFields as $name => $fields) {
             if ($fields->getOptions()['label']) {
                 $attributes[$name] = $fields->getOptions()['label'];
             }
         }
         return $attributes;
     }
     return [];
 }