public function getIndex() { $now = Carbon::now('Asia/Kuala_Lumpur'); $monthStart = $now->startOfMonth(); $monthEnd = $now->endOfMonth(); $tempahan = Order::orderBy('created_at', $monthStart); // where('created_at', '>=', Carbon::now()->startOfMonth())->get() $kato = Category::whereHas('transaction', function ($query) { $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear()); })->get(); $katoo = Category::whereHas('transaction', function ($query) { $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfMonth()); })->get(); $overall = Transaction::select('id', 'created_at', 'month', DB::raw('sum(qty) as total'))->groupBy(DB::raw('MONTH(month)'))->orderBy('created_at', 'asc')->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear())->get(); $testo = Transaction::select('id', 'month')->groupBy(DB::raw('MONTH(month)'))->orderBy('month', 'asc'); $tahun = Carbon::now('Asia/Kuala_Lumpur')->startOfYear(); $tran = Transaction::all(); $tops = Transaction::orderBy('qty', 'desc')->groupBy('product_id')->limit(5)->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfWeek())->get(); return view('a.index', compact('kato', 'katoo', 'tops', 'overall', 'tahun', 'testo'))->with('tempahan', $tempahan)->with('trans', $tran)->with('args', Order::all())->with('ris', Order::sum('total_purchase'))->with('name', $kato->lists('name'))->with('namo', $katoo->lists('name')); }
return ['title' => $faker->text(30), 'file_name' => $match[0]]; }); $factory->define(App\Gallery::class, function (Faker\Generator $faker) { $img = $faker->image('public/assets/img/galleries', 973, 615); preg_match('/(\\w+\\.jpg)/', $img, $match); return ['file_name' => $match[0], 'company_id' => mt_rand(1, 3), 'title' => $faker->text(30)]; }); $factory->define(App\ProductSika::class, function (Faker\Generator $faker) { return ['title' => $faker->text(30), 'description' => '<p>' . $faker->text(255) . '</p>', 'package' => '<p>' . $faker->text(30) . '</p>', 'package_list' => '<p><strong>Упаковка:</strong> 10 л</p>', 'characteristics' => '<p>' . $faker->text(255) . '</p>', 'using_area' => '<p>' . $faker->text(255) . '</p>', 'photo' => $faker->image('public/assets/img/products/sika', 260, 370, NULL, FALSE), 'category_id' => 2, 'enabled' => TRUE, 'tech_cart_file' => $faker->file(base_path('resources/tech_carts'), base_path('public/assets/img/products/sika/tech-carts'), FALSE)]; }); $factory->define(App\ProductPrimer::class, function (Faker\Generator $faker) { return ['title' => $faker->text(30), 'category_id' => \App\Category::whereHas('group_category', function ($q) { $q->whereHas('company', function ($q) { $q->whereShortTitle('primer'); }); })->first()->id, 'photo' => $faker->image('public/assets/img/products/primer', 260, 370, NULL, FALSE), 'description_small' => $faker->text(100), 'description_full' => '<p>' . $faker->text(300) . '</p>', 'package' => '1 л., 2 л., 3 л., 4 л.', 'using' => '<p>' . $faker->text(255) . '</p>', 'tech_characteristics' => '<p>' . $faker->text(255) . '</p>', 'exec_works' => '<p>' . $faker->text(255) . '</p>', 'application' => NULL, 'properties_using' => NULL, 'phys_chem_properties' => NULL, 'restrictions' => NULL, 'safety' => NULL, 'general_characteristics' => NULL, 'price_1_name' => '1 л.', 'price_1_val' => '10 грн', 'price_2_name' => '2 л.', 'price_2_val' => '20 грн', 'price_3_name' => '3 л.', 'price_3_val' => '30 грн', 'price_4_name' => '4 л.', 'price_4_val' => '40 грн', 'enabled' => TRUE]; }); $factory->define(App\ProductSfs::class, function (Faker\Generator $faker) { return ['title' => $faker->text(30), 'category_id' => \App\Category::whereHas('group_category', function ($q) { $q->whereHas('company', function ($q) { $q->whereShortTitle('sfs'); }); })->first()->id, 'file_name' => $faker->file(base_path('resources/tech_carts'), base_path('public/assets/img/products/sfs'), FALSE), 'enabled' => TRUE]; }); $factory->define(App\Partner::class, function (Faker\Generator $faker) { return ['title' => $faker->text(50), 'description' => '<p>' . $faker->text(200) . '</p>', 'web_site' => $faker->domainName(), 'category' => $faker->text(15), 'image' => $faker->image('public/assets/img/partners/', 140, 140, 'business', FALSE), 'enabled' => true]; }); $factory->define(App\Project::class, function (Faker\Generator $faker) { $title = $faker->text(50); return ['title' => $title, 'slug' => str_slug($title), 'description_short' => '<p>' . $faker->text(200) . '</p>', 'description_full' => '<p>' . $faker->text(600) . '</p>', 'image' => $faker->image('public/assets/img/projects/', 140, 140, 'city', FALSE), 'enabled' => true]; });
Route::get('/hotspots/{hotspotId}', function ($hotspotId) { $hotspot = \App\Hotspot::find($hotspotId); return response()->json($hotspot); }); Route::get('/categories', function () { $lat = \Illuminate\Support\Facades\Input::get('lat', -27.49611); $lon = \Illuminate\Support\Facades\Input::get('lon', 153.00207); $radius = 50; // Get city for lat lon $city = \App\City::select(DB::raw("*, (6371 * acos( cos( radians({$lat}) ) * cos( radians( latitude ) ) * cos( radians( {$lon} ) - radians(longitude) ) + sin( radians({$lat}) ) * sin( radians(latitude) ) )) AS distance"))->having('distance', '<', $radius)->orderby('distance', 'asc')->first(); if (!$city) { abort(400, 'City not supported.'); } // get all the categories in the cities $categories = \App\Category::whereHas('ranks', function ($query) use($city) { $query->where('city_id', '=', $city->id); })->get(); return response()->json($categories); }); Route::get('/categories/{categoryId}', function ($categoryId) { $category = \App\Category::find($categoryId); return response()->json($category); }); Route::get('/categories/{categoryId}/places', function ($categoryId) { $lat = \Illuminate\Support\Facades\Input::get('lat', -27.49611); $lon = \Illuminate\Support\Facades\Input::get('lon', 153.00207); // Check if a valid location $radius = 25; $city = \App\City::select(DB::raw("*, (6371 * acos( cos( radians({$lat}) ) * cos( radians( latitude ) ) * cos( radians( {$lon} ) - radians(longitude) ) + sin( radians({$lat}) ) * sin( radians(latitude) ) )) AS distance"))->having('distance', '<', $radius)->orderby('distance', 'asc')->first(); if (!$city) { abort(400, 'City not supported.');