コード例 #1
0
 /**
  * Публикация сообщения
  */
 public function create()
 {
     $guest = new Guestbook();
     $guest->token = Request::input('token', true);
     $guest->captcha = Request::input('captcha');
     $guest->user_id = User::get('id');
     $guest->text = Request::input('text');
     $guest->ip = App::getClientIp();
     $guest->brow = App::getUserAgent();
     if ($guest->save()) {
         // Вынести в after_save
         if (User::check()) {
             $user = User::get();
             $user->allguest = $user->allguest + 1;
             $user->point = $user->point + 1;
             $user->money = $user->money + 20;
             $user->save();
         }
         App::setFlash('success', 'Сообщение успешно добавлено!');
     } else {
         App::setFlash('danger', $guest->getErrors());
         App::setInput($_POST);
     }
     App::redirect('/guestbook');
 }