function traitEntityEdit()
 {
     //соберем форму
     $this->traitEntityEdit_formBuild();
     $this->form->initValues($this->model->toForm());
     $this->traitEntityEdit_formBuildAfter();
     if ($this->form->isSubmitted()) {
         $model_class = static::getClassModel();
         $data = $this->form->getValue();
         $data['id'] = $this->model->id;
         $validator = $model_class::getDataValidator($data, $this->form);
         //            dd($data);
         if ($validator->validate()) {
             //запись успешно сохранена
             $this->traitEntity_save($validator);
             //выведем сообщение об успешной вставке
             return $this->traitEntityEdit_success();
         } else {
             \Debugbar::addMessage($validator->getErrors());
             $this->form->setErrors($validator->getErrors());
             //$this->form->putTbStatic(\HtmlDiv::addClass('alert alert-danger')->setContent($validator->getErrors(true)));
         }
         //запись успешно сохранена
         //            $this->traitEntity_save();
         //            выведем сообщение об успешной вставке
         //            return $this->traitEntityEdit_success();
     }
     //форма показана в первый раз или с ошибками
     if (\Request::ajax()) {
         return $this->traitEntityEditJson();
     }
     return $this->traitEntityEditHtml();
 }
 function traitEntityAdd()
 {
     //соберем форму
     $this->traitEntityAdd_formBuild();
     $this->traitEntityAdd_formBuildAfter();
     /** @var Model $model_class */
     $model_class = static::getClassModel();
     if ($this->form->isSubmitted()) {
         $validator = $model_class::getDataValidator($this->form->getValue(), $this->form);
         if ($validator->validate()) {
             //запись успешно сохранена
             $this->traitEntity_save($validator);
             //выведем сообщение об успешной вставке
             return $this->traitEntityAdd_success();
         } else {
             //                dd($validator->getErrors());
             \Debugbar::addMessage($validator->getErrors());
             $this->form->setErrors($validator->getErrors());
         }
     } else {
         $fill_labels = $this->model->getFillable();
         foreach ($fill_labels as $fillable) {
             if (null !== \Input::get($fillable)) {
                 $this->form->initValues([$fillable => \Input::get($fillable)]);
             }
         }
     }
     //форма показана в первый раз или с ошибками
     if (\Request::ajax()) {
         return $this->traitEntityAddJson();
     } else {
         return $this->traitEntityAddHtml();
     }
 }
Beispiel #3
0
 /**
  * @param $password
  * @param $loginName
  * @param bool $flag
  * @return Users
  */
 public function getUserByCredential($password, $loginName, $flag = null)
 {
     if ($flag == null) {
         $flag = false;
     }
     \Debugbar::info($flag);
     // TODO: Implement getUserByCredential() method.
     if (!$flag) {
         $user = $this->model->newQuery()->with('getGroup')->where('email', '=', $loginName)->where('ugroup', '!=', 2)->where('Active', '=', 1)->first();
         if ($user != null) {
             if (\Hash::check($password, $user->getPassword())) {
                 \Debugbar::addMessage('hash matches - ' . Hash::make($password));
                 return $user;
             } else {
                 \Debugbar::addMessage('hash dose not match');
                 return null;
             }
         } else {
             return null;
         }
     } else {
         $user = $this->model->newQuery()->with('getGroup')->where('Password', '=', $password)->where('email', '=', $loginName)->where('Active', '=', 1)->first();
         if ($user != null) {
             return $user;
         } else {
             return null;
         }
     }
 }
Beispiel #4
0
 public static function console($var)
 {
     if (!class_exists('Debugbar') || app()->environment() === 'testing') {
         return;
     }
     \Debugbar::addMessage($var);
 }
Beispiel #5
0
 /**
  * @param \HTML_QuickForm2_Node $element
  *
  * @return \HTML_QuickForm2_Node
  */
 function initElement(\HTML_QuickForm2_Node $element)
 {
     \Debugbar::addMessage(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
     $config = \Config::get(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
     if (is_array($config)) {
         foreach ($config as $k => $v) {
             $method = \Str::camel('set_' . $k);
             if (is_callable([$element, $method])) {
                 call_user_func([$element, $method], $v);
             }
         }
     }
     return $element;
 }
 public function index()
 {
     \Redis::set('name', 'alegriaghost');
     $name = \Redis::get('name');
     \Redis::del('name');
     \Debugbar::info($name);
     \Debugbar::warning($name);
     \Debugbar::error($name);
     \Debugbar::addMessage($name, '$name');
     var_dump($name);
     \Redis::set('name1', 'alegriaghost1');
     \Redis::set('name2', 'alegriaghost2');
     \Redis::set('name3', 'alegriaghost3');
     $list = Redis::keys('*');
     $values = Redis::mget($list);
     var_dump($list);
     var_dump($values);
 }
Beispiel #7
0
Route::get('/login', 'Auth\\AuthController@getLogin');
# Process login form
Route::post('/login', 'Auth\\AuthController@postLogin');
# Process logout
Route::get('/logout', 'Auth\\AuthController@getLogout');
# Show registration form
Route::get('/register', 'Auth\\AuthController@getRegister');
# Process registration form
Route::post('/register', 'Auth\\AuthController@postRegister');
// Debugging
Route::get('/practice', function () {
    $data = array('foo' => 'bar');
    Debugbar::info($data);
    Debugbar::error('Error!');
    Debugbar::warning('Watch out…');
    Debugbar::addMessage('Another message', 'mylabel');
    return 'Practice';
});
Route::get('/confirm-login-worked', function () {
    # You may access the authenticated user via the Auth facade
    $user = Auth::user();
    if ($user) {
        echo 'You are logged in.';
        dump($user->toArray());
    } else {
        echo 'You are not logged in.';
    }
    return;
});
Route::get('/debug', function () {
    echo '<pre>';
Beispiel #8
0
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
/* Admin routes */
Route::get('admin/login', ['as' => 'login', function () {
    if (\Dobby::isLoggedIn()) {
        Debugbar::addMessage('redirect to admin');
        return redirect('admin');
    }
    return view('admin.login');
}]);
Route::post('admin/login', array('as' => 'login', 'uses' => 'Admin\\LoginController@login'));
Route::get('admin/logout', ['as' => 'logout', function () {
    Dobby::logout();
    return redirect('admin');
}]);
Route::get('logout', function () {
    Dobby::logout();
    return redirect('/');
});
Route::group(['middleware' => 'auth.dobby', 'prefix' => 'admin'], function () {
    Route::get('/', ['as' => 'admin', function () {
Beispiel #9
0
 /**
  * @param      $data
  * @param null $form
  *
  * @return DataValidator
  */
 static function getDataValidator($data, $form = null)
 {
     $v = static::getVendor();
     if ($v) {
         $v .= '::';
     }
     $filters = (array) \Config::get($v . 'models/' . static::getEntity() . '/filters');
     $rules = (array) \Config::get($v . 'models/' . static::getEntity() . '/rules');
     $rules = Arr::only($rules, array_keys($data));
     //        dump($data);
     //        dd($rules);
     //        dump($rules);
     //        \Debugbar::addMessage($rules);
     \Debugbar::addMessage($data);
     $labels = static::getEntityLabels();
     $messages = static::getEntityValidationMessage();
     \Debugbar::addMessage($labels);
     \Debugbar::addMessage($messages);
     foreach ($filters as $field => $field_filters) {
         //            $field_filters = ['trim'] + $field_filters;
         foreach ($field_filters as $field_filter) {
             $elements = $form ? $form->getElementsByName($field) : [];
             $options = [];
             $options[] = Arr::get($data, $field);
             if ($field_filter instanceof \Closure) {
                 $options[] = $data;
                 $options[] = $elements;
             }
             if (isset($data[$field])) {
                 $data[$field] = call_user_func_array($field_filter, $options);
             }
         }
     }
     $class = static::getClassDataValidator();
     $validator = new $class();
     return $validator->setData((array) $data)->setRules((array) $rules)->setLabels((array) $labels)->setMessages((array) $messages);
 }
Beispiel #10
0
 /**
  *
  */
 public function isLoggedIn()
 {
     if ($this->request->session()->get('isLogged') == 1) {
         \Debugbar::addMessage("logged");
         return true;
     } else {
         \Debugbar::addMessage("not logged");
         return false;
     }
 }