Ejemplo n.º 1
0
 /**
  * Save a new status
  *
  * @return Response
  */
 public function store()
 {
     $this->publishStatusForm->validate(Input::only('body'));
     $this->execute(new PublishStatusCommand(Input::get('body'), Auth::user()->id));
     Flash::message('Your status has been updated!');
     return Redirect::refresh();
 }
Ejemplo n.º 2
0
 /**
  * Process login, only for POST http method
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function login()
 {
     /**
      * Get input values
      */
     $credentials = array('username' => Input::get('username'), 'password' => Input::get('password'));
     /**
      * Get remember me checkbox value ('on' or null)
      */
     $rememberme = Input::get('rememberme', false);
     /**
      * Check username or password is not empty
      */
     if ($credentials['username'] == '' or $credentials['password'] == '') {
         return Redirect::route('login')->withInput(Input::except('password'))->with('error', 'Username or password cannot be blank');
     }
     /**
      * Attempt to authenticate
      */
     if (Auth::attempt($credentials, $rememberme)) {
         /**
          * Get session variable 'redirect' for previous page
          */
         if ($url = Session::get('redirect', false)) {
             Session::forget('redirect');
             return Redirect::to($url);
         }
         return Redirect::refresh();
     }
     /**
      * If authentication failed, redirect to login page
      */
     return Redirect::route('login')->withInput(Input::except('password'))->with('error', 'Wrong username or password');
 }
Ejemplo n.º 3
0
 /**
  * Shortcut for request data validation.
  *
  * Ex:
  * <code>
  *  $err = Util::validate(...);
  *  if ($err) return $err;
  * </code>
  *
  * @param array $rules
  * @param array $messages
  * @param array $customAttributes
  *
  * @return bool|\Illuminate\Http\RedirectResponse
  */
 public static function validate(array $rules, array $messages = array(), array $customAttributes = array())
 {
     $validator = Validator::make(Input::all(), $rules, $messages, $customAttributes);
     if ($validator->fails()) {
         self::flash(Lang::get('app.formValidationFailed'));
         return Redirect::refresh()->withErrors($validator)->withInput();
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * creates a new post
  * logs you in as anonymous if you are logged out
  * redirects to new post on success or back on error
  *
  * @param string  $section_title
  * @return Illuminate\Http\RedirectResponse
  */
 public function create($section_title)
 {
     $anon = $this->anon->make(Input::get('captcha'));
     if (!$anon->success) {
         return Redirect::refresh()->withErrors($anon->errorMessage())->withInput();
     }
     $post = $this->post->make(Input::get('section', ''), Input::get('data', ''), Input::get('title', ''), Input::get('url', ''), Input::get('nsfw-tag', 0), Input::get('nsfl-tag', 0), $this->section);
     if ($post->success) {
         $location = sprintf("/s/%s/posts/%s/%s", $post->data->section_title, $post->data->item_id, $post->data->item_title);
         return Redirect::to($location);
     } else {
         return Redirect::back()->withErrors($post->errorMessage())->withInput();
     }
 }
Ejemplo n.º 5
0
 /**
  * Traitement du formulaire d'inscription
  *
  * @return Redirect
  */
 public function postInscription()
 {
     $v = User::validate(Input::all());
     if ($v->passes()) {
         $user = new User();
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->password = Hash::make(Input::get('password'));
         $user->confirmation_code = str_random(30);
         $data = array('confirmation_code' => $user->confirmation_code);
         Mail::send('mail.layout', $data, function ($message) {
             $message->to(Input::get('email'), Input::get('username'))->subject('Echyzen : Verify your email address');
         });
         $user->save();
         return Redirect::back()->with('flash_notice', 'Votre compte a été créé.');
     }
     return Redirect::refresh()->withErrors($v)->withInput();
 }
 public function moder($id)
 {
     /**
      * @var $obj Vacancy
      */
     $obj = Vacancy::findOrFail($id);
     if (!empty($_POST)) {
         $data = Input::only(array('active', 'email', 'title', 'text'));
         $validation = $obj->validate($data);
         if ($validation->fails()) {
             return Redirect::refresh()->with('message', array('text' => $validation->errors()->first()))->withInput($data);
         } else {
             $obj->fill($data);
             $obj->save();
             return Redirect::refresh()->with('message', array('text' => 'Вакансия успешно сохранена'));
         }
     }
     return View::make('vacancies.moder', array('item' => $obj));
 }
Ejemplo n.º 7
0
<?php

Route::get('buy', function () {
    return View::make('buy');
});
Route::post('buy', function () {
    $billing = App::make('Acme\\Billing\\BillingInterface');
    try {
        $customerId = $billing->charge(['email' => Input::get('email'), 'token' => Input::get('stripe-token')]);
        $user = User::first();
        $user->billing_id = $customerId;
        $user->save();
    } catch (Exception $e) {
        return Redirect::refresh()->withFlashMessage($e->getMessage());
    }
    return 'Charge was successful';
});