| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WelcomeController@index');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::group(['middleware' => 'auth'], function () {
    Route::get('home', function () {
        $user = Auth::user();
        return view('home', ['user' => $user]);
    });
    /**
     *	Request to Save and Execute the code
     */
    Route::post('home', 'CodeController@saveAndExec');
    Route::get('/codes', function () {
        $user = Auth::user();
        if ($user->role != 'Moderator') {
            return Redirect::to('/home');
        }
        $codes = App\Code::all();
        return view('codes', ['codes' => $codes]);
    });
    Route::get('/codes/{user_id}', function ($user_id) {
        $user = Auth::user();
        if ($user->role != 'Moderator') {
            return Redirect::to('/home');
        }
        $code = App\Code::where('user_id', '=', $user_id)->first();
        return view('code', ['code' => $code->code]);
    });
});
예제 #2
0
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in 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');
});
Route::get('api/validate/{cipher}', ['middleware' => 'auth.basic', 'uses' => function ($cipher) {
    $code = App\Code::find($cipher);
    if ($code == null) {
        return Response::make(['message' => 'Invalid code.'], 500);
    }
    return Response::make(['value' => $code->value]);
}]);
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
예제 #3
0
<?php

Route::resource('request-tv-token', 'TokenGenerationController', ['only' => ['store']]);
Route::resource('exchange-tokens', 'ExchangeTokensController', ['only' => ['show', 'update', 'destroy']]);
Route::get('{token}/complete', function ($token) {
    $code = App\Code::where('token', $token)->first();
    if ($code) {
        $code->access_token = $_GET['access_token'];
        $code->save();
    }
    return view('complete');
});
Route::get('{id}', function ($id) {
    $code = App\Code::where('url', $id)->first();
    if (!$code) {
        return app()->abort(404);
    }
    return view('redirecting', ['token' => $code->token]);
});
Route::get('/', function () {
    return redirect('http://getfetchapp.com');
});
예제 #4
0
파일: routes.php 프로젝트: hnadir/a3
<?php

/*
|--------------------------------------------------------------------------
| 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');
});
Route::model('codes', 'Code');
Route::model('users', 'User');
Route::resource('users', 'UsersController');
Route::resource('users.codes', 'CodesController');
Route::bind('codes', function ($value, $route) {
    return App\Code::whereId($value)->first();
});
Route::bind('users', function ($value, $route) {
    return App\User::whereId($value)->first();
});
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
예제 #5
0
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
    Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
    // Route::controller('')
    /**
     * For Logged in users only
     */
    Route::group(['middleware' => ['auth']], function () {
        Route::get('/home', function () {
            // $user_id = 1;
            $user_id = Auth::user()->id;
            return redirect()->route('home', ['user_id' => $user_id]);
        });
        // for user to view & edit code
        // named route for logged in user's home
        Route::get('/{user_id}/ide', ['as' => 'home', 'uses' => 'CodeController@getIDE']);
        // for user to save & execute code
        Route::post('/{user_id}/ide', 'CodeController@saveExecCode');
        Route::get('/codes', function () {
            // list of codes
            $codes = App\Code::all();
            return view('codes', ['codes' => $codes]);
        });
        // for admin to view code
        Route::get('/{user_id}/code', 'CodeController@getCode');
    });
});