Пример #1
0
|				Route::bind('user', function($value, $route)
|				{
|				    return User::where('name', $value)->first();
|				});
*/
/*==========================================================
|    							PRODUCTS DEPENDENCY INJECTION
==========================================================*/
Route::bind('product', function ($slug) {
    return App\Product::where('slug', $slug)->first();
});
/*==========================================================
|    							CATEGORY DEPENDENCY INJECTION
==========================================================*/
Route::bind('category', function ($category) {
    return App\Category::find($category);
});
/*==========================================================
|    							USER DEPENDENCY INJECTION
==========================================================*/
Route::bind('user', function ($user) {
    return App\User::find($user);
});
/*==========================================================
|  													HOME
==========================================================*/
Route::get('/', ['as' => 'home', 'uses' => 'StoreController@index']);
Route::get('product/{slug}', ['as' => 'product-detail', 'uses' => 'StoreController@show']);
/*
|-------------------------------------------------------------
|Carrito de compras
Пример #2
0
});
Route::get('/update', function () {
    $category = App\Category::find(6);
    $category->name = "HEAVY METAL";
    $category->save();
});
Route::get('/delete', function () {
    $category = App\Category::find(5);
    $category->delete();
    $categories_list = $category->all(array('name', 'id'));
    foreach ($categories_list as $categories_list_item) {
        echo $categories_list_item->id . ' ' . $categories_list_item->name . '<br />';
    }
});
//API building part of Laravel tutorial
Route::get('/api/v1/products/{id?}', array('middleware' => 'auth.basic', function ($id = null) {
    if ($id == null) {
        $products = App\Product::all(array('id', 'name', 'price'));
    } else {
        $products = App\Product::find($id, array('id', 'name', 'price'));
    }
    return Response::json(array('error' => false, 'products' => $products, 'status_code' => 200));
}));
Route::get('/api/v1/categories/{id?}', array('middleware' => 'auth.basic', function ($id = null) {
    if ($id == null) {
        $categories = App\Category::all(array('id', 'name'));
    } else {
        $categories = App\Category::find($id, array('id', 'name'));
    }
    return Response::json(array('error' => false, 'user' => $categories, 'status_code' => 200));
}));
Пример #3
0
    App\Category::create(array('name' => 'Music'));
    return 'category added';
});
Route::get('/insert', function () {
    App\Category::create(array('title' => 'HIROKI'));
    return 'category added';
});
Route::get('/read', function () {
    $category = new App\Category();
    $data = $category->all(array('title', 'id'));
    foreach ($data as $list) {
        echo $list->id . ' ' . $list->title . ' ';
    }
});
Route::get('/update', function () {
    $category = App\Category::find(1);
    $category->title = 'HEAVY METAL';
    $category->save();
    $data = $category->all(array('title', 'id'));
    foreach ($data as $list) {
        echo $list->id . ' ' . $list->title . '
';
    }
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
Пример #4
0
    $data = $category->all(array('name', 'id'));
    foreach ($data as $list) {
        echo $list->id . ' ' . $list->name . '<br>';
    }
});
Route::get('/update', function () {
    $category = App\Category::find(16);
    $category->name = 'HEAVY METAL';
    $category->save();
    $data = $category->all(array('name', 'id'));
    foreach ($data as $list) {
        echo $list->id . ' ' . $list->name . '<br>';
    }
});
Route::get('/delete', function () {
    $category = App\Category::find(5);
    $category->delete();
    $data = $category->all(array('name', 'id'));
    foreach ($data as $list) {
        echo $list->id . ' ' . $list->name . '<br>';
    }
});
Route::get('/raw', function () {
    $sql = "INSERT INTO categories (name) VALUES ('POMBE')";
    DB::statement($sql);
    $results = DB::select(DB::raw("SELECT * FROM categories"));
    print_r($results);
});
Route::get('blade', function () {
    $drinks = array('Vodka', 'Gin', 'Brandy');
    return view('page', array('name' => 'The Raven', 'day' => 'Friday', 'drinks' => $drinks));
Пример #5
0
    //        $html[] = Form::getSelectOption($display, $value, $selected);
    //    }
    $list = implode('', $html);
    $options = HTML::attributes($options);
    return "<select{$options}>{$list}</select>";
});
Route::get('hell', function (Request $request) {
    //    $this->app['auth']->admin()->setUser(\App\Customer::find(1));
    //    throw new \App\Exceptions\LoginException($request);
    //    $credentials = [
    //        'email' => '*****@*****.**',
    //        'password' => 'asd123.'
    //    ];
    //    $re = Auth::customer()->attempt($credentials);
    //    echo 'ok ' . $re;
    $cat = App\Category::find(2);
    $cats = [];
    echo response()->json(App\Category::hasChildren()->get());
});
Route::get('slurp', function (App\Repositories\HomeRepository $c) {
    $items = App\Advertisement::with('images')->where('id', '>', 100)->select('id', 'title', 'description', 'price', DB::raw('0 as type'));
    $products = App\Globex::with('images')->where('id', '>', 998)->select('id', 'title', 'description', 'price', DB::raw('1 as type'));
    return response()->json($items->union($products->getQuery())->get());
});
Route::get('ajax', function () {
    return 'ookay';
});
Route::get('motors', function () {
    $data = ['cats' => App\Category::whereDepth(2)->lists('name', 'id'), 'motors' => App\Motor::all()];
    return view('temp.motors', $data);
});