Exemplo n.º 1
0
 public function get_single($logfile)
 {
     $logfiles = Helpers::logfiles();
     $logs = Helpers::logs($logfile);
     $this->layout->title = 'Logs';
     $this->layout->nest('content', 'adminify::logs.single', array('logfiles' => $logfiles, 'logfile' => $logfile, 'logs' => $logs));
 }
Exemplo n.º 2
0
 public function get_edit($model = null, $id = null)
 {
     $name = $model;
     if (is_null($model) || is_null($id)) {
         return Redirect::to(Adminify\Libraries\Helpers::url('/'));
     }
     $model = Helpers::getModel($model);
     if (is_null($model)) {
         return Redirect::to(Adminify\Libraries\Helpers::url('/'));
     }
     $entry = $model::find($id);
     $table = property_exists($model, 'table') && !is_null($model::$table) ? $model::$table : strtolower(Str::plural($model));
     $structure = DB::query("SHOW COLUMNS FROM `" . $table . "`");
     $excluded = Helpers::getFields($model);
     $this->layout->title = 'Edit ' . $model;
     $this->layout->nest('content', 'adminify::models.edit', array('entry' => $entry, 'model' => $model, 'name' => $name, 'structure' => $structure, 'excluded' => $excluded));
 }
Exemplo n.º 3
0
 public function post_add($model)
 {
     $name = $model;
     $input = Input::all();
     unset($input['csrf_token']);
     $rules = Config::get('Adminify::settings.validation');
     $messages = Config::get('Adminify::settings.messages');
     $validation = Validator::make($input, $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation)->with_input();
     }
     if (isset($input['password'])) {
         $input['password'] = Hash::make($input['password']);
     }
     $model = Adminify\Libraries\Helpers::getModel($model);
     $model::create($input);
     return Redirect::to('/admin/models/' . $name)->with('added', true);
 }
Exemplo n.º 4
0
 public function put_edit($model, $id)
 {
     $name = $model;
     $input = Input::all();
     unset($input['csrf_token']);
     $rules = Config::get('Adminify::settings.validation');
     $messages = Config::get('Adminify::settings.messages');
     $validation = Validator::make($input, $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation)->with_input();
     }
     if (isset($input['password'])) {
         $input['password'] = Hash::make($input['password']);
     }
     $model = Helpers::getModel($model);
     $model = $model::find($id);
     foreach ($input as $key => $i) {
         $model->{$key} = $i;
     }
     $model->save();
     return Redirect::back()->with('updated', true);
 }