public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('order_items')->delete();
     for ($i = 0; $i < 300; $i++) {
         $globex = App\Globex::find(rand(1, 200));
         App\OrderItem::create(['order_id' => rand(1, 100), 'product_id' => $globex->product->id, 'price' => $globex->product->price]);
     }
 }
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('products_globex')->delete();
     $faker = $this->getFaker();
     $categories = App\Category::allLeaves()->get();
     $category_count = count($categories);
     for ($i = 0; $i < 200; $i++) {
         $product = App\Product::create(['title' => $faker->sentence(rand(1, 3)), 'price' => rand(5, 50000), 'description' => $faker->sentence(), 'brand' => $faker->company, 'category_id' => $categories[rand(0, $category_count - 1)]->id]);
         $product->images()->create(['url' => '/img/noImage.jpg']);
         $globex = App\Globex::create(['stock' => rand(0, 100), 'price_rule_id' => rand(1, 10)]);
         $globex->product()->save($product);
     }
 }
Beispiel #3
0
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);
});
Route::post('motors', function () {
    App\Motor::create(['title' => Input::get('title'), 'price' => Input::get('price'), 'stock' => Input::get('stock'), 'brand' => Input::get('brand'), 'description' => Input::get('description'), 'category_id' => Input::get('category_id'), 'chassis_no' => Input::get('chassis_no'), 'model' => Input::get('model'), 'color' => Input::get('color')]);
    return redirect()->back();
});
Route::get('shitzu', function (AdminPanelRepository $repository) {
    //    return response()->json(array_search('admin/products', array_column($repository->getPages(), 'request', 'title')));