/** * Paginate my products. */ public function testMyProductsPagination() { $numberOfProducts = 45; // Generate user and products $user = factory(App\User::class)->create(); for ($i = 0; $i < $numberOfProducts; $i++) { $user->products()->save(factory(App\Product::class)->make()); } $paginate = App\Product::where('user_id', $user->id)->orderBy('code', 'asc')->paginate(10); $this->actingAs($user)->get('/my-products/get')->seeJson(['total' => $paginate->total(), 'per_page' => $paginate->perPage()]); }
<?php $categories = App\Category::where('active', 1)->get(['id', 'name']); ?> <select class="form-control" name="category_id" id="category_id" required> <option value="">-select-</option> @foreach( $categories as $category ) <option value="{{ $category->id }}">{{ $category->name }} </option> @endforeach </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label or="product_id">Product/Area</label> <?php $products = App\Product::where('active', 1)->get(['id', 'name']); ?> <select class="form-control" name="product_id" id="product_id" required> <option value="">-select-</option> @foreach( $products as $product ) <option value="{{ $product->id }}">{{ $product->name }} </option> @endforeach </select> </div> </div> </div> <div class="row"> <div class="col-md-6">
*/ /* | dependiendo del slug de la url, buscamos el producto en la bd con el mismo slug y |traemos los datos relacionados al producto. |Sometimes you may wish to use your own resolver for route parameters. Simply use the Route::bind method: | | 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
function kalMenuFromSlug($slug, $with_parent = false) { $subs = App\Product::where('slug', $slug)->first()->getSubs(); return kalMenu($subs); }