Exemplo n.º 1
0
 /**
  * Display a listing of exchanges request to current user
  *
  * @return Response
  */
 public function index()
 {
     $datas = Input::all();
     if (!empty($datas['user_id']) && !empty($datas['action'])) {
         $user_id = $datas['user_id'];
         $messages = array();
         if (FEUsersHelper::isCurrentUser($user_id)) {
             $user = User::find($user_id);
             if ($datas['action'] == 'receive') {
                 $exchanges = Exchange::where('r_user_id', '=', $user_id)->where('status', '=', 0)->where('created_at', '>=', $user->last_check_noti)->get();
                 return View::make('frontend/exchanges/receive')->with('exchanges', $exchanges);
             } elseif ($datas['action'] == 'send') {
                 $exchanges = Exchange::where('s_user_id', '=', $user_id)->where('created_at', '>=', $user->last_check_noti)->get();
                 return View::make('frontend/exchanges/send')->with('exchanges', $exchanges);
             }
         } else {
             Session::flash('status', false);
             $messages[] = 'Không được phép truy cập';
             Session::flash('messages', $messages);
             return Redirect::to('/');
         }
     }
 }
Exemplo n.º 2
0
 public function getIndex()
 {
     $this->layout->title = 'Home';
     $exchanges = Exchange::where('hidden', 0)->orderBy('draw_at', 'asc')->paginate(Config::get('settings.per_page'));
     $this->layout->nest('content', 'home', ['exchanges' => $exchanges]);
 }
Exemplo n.º 3
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 Closure to execute when that URI is requested.
|
*/
App::missing(function ($exception) {
    $layout = View::make("layout.main");
    $layout->title = 'Not Found';
    $layout->content = View::make("errors.missing")->with('exception', $exception->getMessage());
    return Response::make($layout, 404);
});
Route::bind('exchange', function ($value) {
    $exchange = Exchange::where('slug', $value)->first();
    if ($exchange) {
        return $exchange;
    }
    App::abort(404, 'Exchange not found!');
});
Route::bind('user', function ($value, $route) {
    $user = User::where('username', $value)->first();
    if ($user) {
        return $user;
    }
    App::abort(404, 'User not found!');
});
Route::when('*', 'csrf', ['post']);
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@getIndex']);
Route::group(['prefix' => 'dashboard', 'before' => 'auth'], function () {