Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

home_categories #261 #260

Merged
merged 4 commits into from
Jul 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;

class CategoryController extends Controller
{
public function show($id)
{
$categories = \App\Product::where('category_id', $id)
->get();
return view('categories')
->with('categories', $categories);
}
}
12 changes: 10 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ class HomeController extends Controller
public function index()
{
$shopProducts = \App\shopProduct::orderBy('id', 'DESC')
->take(3)
->take(4)
->get();
$sp = \App\shopProduct::orderBy('buys', 'DESC')
->take(3)
->take(4)
->get();
return view('home')
->with('shopProducts', $shopProducts)
->with('sp', $sp);
}

public function search(Request $req)
{
$products = \App\Product::where('name', 'Like', '%' . $req->key . '%')
->get();
return view('search')
->with('products', $products);
}
}
69 changes: 66 additions & 3 deletions database/seeds/ProductsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,72 @@ class ProductsTableSeeder extends Seeder
public function run()
{
DB::table('products')->insert([
['id' => 1, 'buys' => '1', 'name' => 'Áo thun nam', 'description' => 'Áo', 'image' => '123', 'view' => '1', 'price' => '300', 'category_id' => '24', 'alias' => 'ao-thun-nam-gia-re'],
['id' => 2, 'buys' => '2', 'name' => 'Váy nữ', 'description' => 'Váy', 'image' => '234', 'view' => '2', 'price' => '400', 'category_id' => '48', 'alias' => 'aaaaa'],
['id' => 3, 'buys' => '3', 'name' => 'Điện thoại iPhone 7', 'description' => 'Điện thoại', 'image' => '345', 'view' => '3', 'price' => '1000', 'category_id' => '6', 'alias' => 'iphone-7']
['id' => 1, 'buys' => '1', 'name' => 'Nokia 2700', 'description' => 'Điện thoại', 'image'=>'nokia2700.jpg', 'view' => '1', 'price' => '300000', 'category_id' => '5', 'alias' => 'nokia-2700'],

['id' => 2, 'buys' => '5', 'name' => 'iphone 6s', 'description' => 'Điện thoại', 'image'=>'iphone6s.jpg', 'view' => '8', 'price' => '7000000', 'category_id' => '6', 'alias' => 'iphone6s'],
['id' => 3, 'buys' => '23', 'name' => 'Áo Khoác dù nam mặc được 2 mặt', 'description' => 'Áo khoác', 'image'=>'aokhoacdunam.jpg', 'view' => '6', 'price' => '200000', 'category_id' => '28', 'alias' => 'ao-khoac-du'],
['id' => 4, 'buys' => '15', 'name' => 'áo khoác kaki 2 túi', 'description' => 'Áo khoác', 'image'=>'aokhoackaki2tui.jpg', 'view' => '7', 'price' => '190000', 'category_id' => '29', 'alias' => 'ao-khoac-kaki'],

['id' => 5, 'buys' => '30', 'name' => 'Áo sơ mi nam tay dài', 'description' => 'Áo sơ mi', 'image'=>'aosomitaydai.jpg', 'view' => '19', 'price' => '200000', 'category_id' => '31', 'alias' => 'ao-so-mi-tay-dai'],
['id' => 6, 'buys' => '40', 'name' => 'Áo sơ mi nam tay ngắn trơn', 'description' => 'Áo sơ mi', 'image'=>'aosomitayngan.jpg', 'view' => '10', 'price' => '210000', 'category_id' => '32', 'alias' => 'ao-so-mi-tay-ngan'],
['id' => 7, 'buys' => '10', 'name' => 'Áo sơ mi phối sọc', 'description' => 'Áo sơ mi', 'image'=>'aosomiphoisoc.jpg', 'view' => '1', 'price' => '200000', 'category_id' => '32', 'alias' => 'ao-so-mi-tay-ngan'],

['id' => 8, 'buys' => '21', 'name' => ' Áo thun tay dài kiểu hàn quốc', 'description' => 'Áo thun tay dài', 'image'=>'aothuntaydaikieuhan.jpg', 'view' => '4', 'price' => '220000', 'category_id' => '33', 'alias' => 'ao-thun-tay-dai-kieu-han-quoc'],

['id' => 9, 'buys' => '29', 'name' => ' Áo thun tay ngắn cổ trụ', 'description' => 'Áo thun tay ngắn', 'image'=>'aothuncotru.jpg', 'view' => '8', 'price' => '129000', 'category_id' => '34', 'alias' => 'ao-thun-tay-ngan-co-tru'],
['id' => 10, 'buys' => '14', 'name' => ' Áo thun cổ chữ V', 'description' => 'Áo thun tay ngắn', 'image'=>'aothuncochuv.jpg', 'view' => '0', 'price' => '190000', 'category_id' => '34', 'alias' => 'ao-thun-co-chu-v'],

['id' => 11, 'buys' => '30', 'name' => 'Quần jean nam suông xám', 'description' => 'quần jean', 'image'=>'jeansuongxam.jpg', 'view' => '3', 'price' => '215000', 'category_id' => '36', 'alias' => 'quan-jean-nam-suong-xam'],
['id' => 12, 'buys' => '29', 'name' => 'Quần jean nam cao cấp', 'description' => 'quần jean', 'image'=>'jeannam.jpg', 'view' => '6', 'price' => '345000', 'category_id' => '36', 'alias' => 'quan-jean-nam-cao-cap'],

['id' => 13, 'buys' => '28', 'name' => 'Quần kaki ống côn', 'description' => 'quần kaki', 'image'=>'kakiongcon.jpg', 'view' => '7', 'price' => '175000', 'category_id' => '39', 'alias' => 'quan-kaki-ong-con'],

['id' => 14, 'buys' => '20', 'name' => 'Quần tây công sở', 'description' => 'quần tây', 'image'=>'quantaynam.jpg', 'view' => '8', 'price' => '285000', 'category_id' => '38', 'alias' => 'quan-tay-cong-so'],

['id' => 15, 'buys' => '22', 'name' => 'Đầm phối ren', 'description' => 'đầm ', 'image'=>'damphoiren.jpg', 'view' => '21', 'price' => '235000', 'category_id' => '48', 'alias' => 'dam-phoi-ren'],

['id' => 16, 'buys' => '26', 'name' => 'Đầm suông thun lụa', 'description' => 'đầm ', 'image'=>'damsuongthunlua.jpg', 'view' => '2', 'price' => '255000', 'category_id' => '49', 'alias' => 'dam-suong-thun-lua'],
['id' => 17, 'buys' => '29', 'name' => 'Đầm ôm sọc ngang', 'description' => 'đầm ', 'image'=>'damsoc.jpg', 'view' => '4', 'price' => '275000', 'category_id' => '50', 'alias' => 'dam-om-soc-ngang'],
['id' => 18, 'buys' => '26', 'name' => 'Đầm ôm đuôi cá', 'description' => 'đầm ', 'image'=>'damduoica.jpg', 'view' => '7', 'price' => '315000', 'category_id' => '50', 'alias' => 'dam-som-duoi-ca'],

['id' => 19, 'buys' => '26', 'name' => 'Vest công sở', 'description' => 'Áo khoác ', 'image'=>'vestcongso.jpg', 'view' => '2', 'price' => '295000', 'category_id' => '51', 'alias' => 'vest-cong-so'],
['id' => 20, 'buys' => '19', 'name' => ' Áo khoác kiểu có mũ', 'description' => ' áo khoác ', 'image'=>'aokhoacnuhan.jpg', 'view' => '9', 'price' => '215000', 'category_id' => '52', 'alias' => 'ao-khoac-kieu-co-mu'],
['id' => 21, 'buys' => '29', 'name' => ' Áo khoác Boober Jacket ', 'description' => ' Áo khoác', 'image'=>'bomberjacket.jpg', 'view' => '6', 'price' => '265000', 'category_id' => '52', 'alias' => 'ao-khoac-boober-jacket'],
['id' => 22, 'buys' => '42', 'name' => ' Áo khoác len chùm ', 'description' => ' Áo khoác ', 'image'=>'aokhoaclen.jpg', 'view' => '9', 'price' => '199000', 'category_id' => '53', 'alias' => 'ao-khoac-len-chum'],
['id' => 23, 'buys' => '32', 'name' => ' Áo khoác len Form dài ', 'description' => ' Áo khoác ', 'image'=>'lenformdai.jpg', 'view' => '9', 'price' => '455000', 'category_id' => '53', 'alias' => 'ao-khoac-len-form-dai'],
['id' => 24, 'buys' => '37', 'name' => ' Áo sơ mi cổ trụ ', 'description' => ' Áo nữ', 'image'=>'aosomicotru.jpg', 'view' => '7', 'price' => '169000', 'category_id' => '54', 'alias' => 'ao-so-mi-co-tru'],
['id' => 25, 'buys' => '25', 'name' => ' Áo sơ mi công sở ', 'description' => ' Áo nữ', 'image'=>'somicongso.jpg', 'view' => '5', 'price' => '169000', 'category_id' => '54', 'alias' => 'ao-so-mi-cong-so'],
['id' => 26, 'buys' => '20', 'name' => ' Áo nữ', 'description' => ' Áo kiểu', 'image'=>'aokieuthacno.jpg', 'view' => '9', 'price' => '179000', 'category_id' => '55', 'alias' => 'ao-kieu-thac-no'],
['id' => 27, 'buys' => '15', 'name' => ' Áo kiểu hở vai ', 'description' => ' Áo nữ', 'image'=>'kieuhovai.jpg', 'view' => '2', 'price' => '159000', 'category_id' => '55', 'alias' => 'ao-kieu-ho-vai'],
['id' => 28, 'buys' => '23', 'name' => 'Áo dài cách tân ren thêu ', 'description' => ' Áo nữ', 'image'=>'aodaicachtan.jpg', 'view' => '4', 'price' => '259000', 'category_id' => '56', 'alias' => 'ao-dai-cach-tan-ren-theu'],

['id' => 29, 'buys' => '34', 'name' => ' Quần jean nữ rách ', 'description' => 'quần nữ', 'image'=>'jeanrachnu.jpg', 'view' => '5', 'price' => '199000', 'category_id' => '57', 'alias' => 'quan-jean-rach-nu'],
['id' => 30, 'buys' => '13', 'name' => ' Quần tây nữ ', 'description' => ' Quần nữ', 'image'=>'quantaynu.jpg', 'view' => '5', 'price' => '279000', 'category_id' => '58', 'alias' => 'quan-tay-nu'],

['id' => 31, 'buys' => '14', 'name' => ' Giày da mũi kim loại cao cấp ', 'description' => ' giày cao gót nữ', 'image'=>'giaydamuikimloai.jpg', 'view' => '4', 'price' => '329000', 'category_id' => '66', 'alias' => 'giay-da-mui-kim-loai'],

['id' => 32, 'buys' => '33', 'name' => ' Giày cao gót mũi hở ánh vàng ', 'description' => ' giày cao gót nữ', 'image'=>'muihoanhvang.jpg', 'view' => '3', 'price' => '310000', 'category_id' => '67', 'alias' => 'giay-cao-got-mui-ho-anh-vang'],

['id' => 33, 'buys' => '25', 'name' => 'Đầm suông nữ', 'description' => 'đầm ', 'image'=>'damsuongnu.jpg', 'view' => '2', 'price' => '195000', 'category_id' => '49', 'alias' => 'dam-suong-nu'],

['id' => 34, 'buys' => '21', 'name' => ' Giày da cao cấp ', 'description' => ' giày nam', 'image'=>'giaydacaocap.jpg', 'view' => '0', 'price' => '350000', 'category_id' => '69', 'alias' => 'giay-da-cao-cap'],

['id' => 35, 'buys' => '23', 'name' => ' iPad Pro 9.7 ', 'description' => ' máy tính bảng', 'image'=>'ipadpro.jpg', 'view' => '7', 'price' => '17500000', 'category_id' => '10', 'alias' => 'ipad-pro-9.7'],
['id' => 36, 'buys' => '11', 'name' => ' Samsung Galaxy tab S3 ', 'description' => ' máy tính bảng', 'image'=>'galaxytabs3.jpg', 'view' => '7', 'price' => '14500000', 'category_id' => '11', 'alias' => 'galaxy-tab-s3'],
['id' => 37, 'buys' => '32', 'name' => ' Dell Vostro V5468A ', 'description' => ' Laptop', 'image'=>'dellvostro.jpg', 'view' => '3', 'price' => '21500000', 'category_id' => '13', 'alias' => 'dell-vostro-v5468A'],
['id' => 38, 'buys' => '31', 'name' => ' Asus UX310UA-FC054T ', 'description' => ' Laptop', 'image'=>'asusux310ua.jpg', 'view' => '3', 'price' => '11500000', 'category_id' => '14', 'alias' => 'asus-ux310ua'],
['id' => 39, 'buys' => '27', 'name' => ' Asus X455LA-WX443D ', 'description' => ' Laptop', 'image'=>'asusx455la.jpg', 'view' => '3', 'price' => '8500000', 'category_id' => '14', 'alias' => 'asus-x455la'],

['id' => 40, 'buys' => '7', 'name' => 'Iphone 7plush ', 'description' => 'Điện thoại', 'image'=>'iphone7plush.jpg', 'view' => '4', 'price' => '26000000', 'category_id' => '6', 'alias' => 'iphone7plush'],

['id' => 41, 'buys' => '10', 'name' => 'Samsung Galaxy S8', 'description' => 'Điện thoại', 'image'=>'samsungs8.jpg', 'view' => '3', 'price' => '18000000', 'category_id' => '7', 'alias' => 'samsung-galaxy-s8'],
['id' => 42, 'buys' => '7', 'name' => 'Iphone 7', 'description' => 'Điện thoại', 'image'=>'iphone7.jpg', 'view' => '3', 'price' => '22000000', 'category_id' => '6', 'alias' => 'iphone7'],
['id' => 43, 'buys' => '20', 'name' => 'Samsung A9', 'description' => 'Điện thoại', 'image'=>'samsunga9.jpg', 'view' => '7', 'price' => '14000000', 'category_id' => '7', 'alias' => 'samsung-a9'],
['id' => 44, 'buys' => '16', 'name' => 'Áo Khoác Nam phối màu sành điệu', 'description' => 'Áo khoác', 'image'=>'aokhoacnam.jpg', 'view' => '4', 'price' => '120000', 'category_id' => '29', 'alias' => 'ao-khoac-nam'],
['id' => 45, 'buys' => '32', 'name' => 'Quần jean rách cao cấp', 'description' => 'quần jean', 'image'=>'quanjeanrach.jpg', 'view' => '17', 'price' => '245000', 'category_id' => '25', 'alias' => 'quan-jean-rach-cao-cap'],

['id' => 46, 'buys' => '32', 'name' => ' Giày cao gót mũi hở kim tuyến ', 'description' => ' giày cao gót nữ', 'image'=>'kimtuyencaocap.jpg', 'view' => '3', 'price' => '350000', 'category_id' => '67', 'alias' => 'giay-cao-got-mui-ho-kim-tuyen']

]);
}
}
51 changes: 48 additions & 3 deletions database/seeds/ShopProductsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,54 @@ class ShopProductsTableSeeder extends Seeder
public function run()
{
DB::table('shop_products')->insert([
['quantity' => '10', 'price' => '300', 'discount' => '10', 'user_id' => '1', 'product_id' => '1', 'buys' => '5', 'shop_id' => '1'],
['quantity' => '10', 'price' => '400', 'discount' => '10', 'user_id' => '2', 'product_id' => '2', 'buys' => '5', 'shop_id' => '2'],
['quantity' => '10', 'price' => '1000', 'discount' => '10', 'user_id' => '3', 'product_id' => '3', 'buys' => '5', 'shop_id' => '3']
['quantity' => '1', 'price' => '300000', 'discount' => '285000', 'user_id' => '1', 'product_id' => '1', 'buys' => '1', 'shop_id' => '1'],
['quantity' => '5', 'price' => '700000', 'discount' => '0', 'user_id' => '2', 'product_id' => '2', 'buys' => '5', 'shop_id' => '2'],
['quantity' => '5', 'price' => '200000', 'discount' => '189000', 'user_id' => '3', 'product_id' => '3', 'buys' => '5', 'shop_id' => '3'],
['quantity' => '13', 'price' => '100000', 'discount' => '0', 'user_id' => '4', 'product_id' => '4', 'buys' => '13', 'shop_id' => '2'],
['quantity' => '20', 'price' => '200000', 'discount' => '0', 'user_id' => '4', 'product_id' => '5', 'buys' => '30', 'shop_id' => '1'],
['quantity' => '20', 'price' => '210000', 'discount' => '0', 'user_id' => '2', 'product_id' => '6', 'buys' => '40', 'shop_id' => '1'],
['quantity' => '5', 'price' => '200000', 'discount' => '0', 'user_id' => '2', 'product_id' => '7', 'buys' => '10', 'shop_id' => '2'],
['quantity' => '20', 'price' => '220000', 'discount' => '0', 'user_id' => '2', 'product_id' => '8', 'buys' => '21', 'shop_id' => '3'],
['quantity' => '20', 'price' => '129000', 'discount' => '119000', 'user_id' => '1', 'product_id' => '9', 'buys' => '29', 'shop_id' => '1'],
['quantity' => '14', 'price' => '190000', 'discount' => '0', 'user_id' => '3', 'product_id' => '10', 'buys' => '14', 'shop_id' => '3'],
['quantity' => '25', 'price' => '215000', 'discount' => '0', 'user_id' => '4', 'product_id' => '11', 'buys' => '30', 'shop_id' => '2'],
['quantity' => '29', 'price' => '215000', 'discount' => '215000', 'user_id' => '3', 'product_id' => '12', 'buys' => '29', 'shop_id' => '2'],
['quantity' => '28', 'price' => '175000', 'discount' => '0', 'user_id' => '2', 'product_id' => '13', 'buys' => '28', 'shop_id' => '1'],
['quantity' => '20', 'price' => '285000', 'discount' => '0', 'user_id' => '3', 'product_id' => '14', 'buys' => '20', 'shop_id' => '3'],
['quantity' => '22', 'price' => '235000', 'discount' => '0', 'user_id' => '1', 'product_id' => '15', 'buys' => '22', 'shop_id' => '2'],
['quantity' => '26', 'price' => '255000', 'discount' => '0', 'user_id' => '1', 'product_id' => '16', 'buys' => '26', 'shop_id' => '2'],
['quantity' => '29', 'price' => '275000', 'discount' => '255000', 'user_id' => '1', 'product_id' => '17', 'buys' => '29', 'shop_id' => '3'],
['quantity' => '26', 'price' => '315000', 'discount' => '0', 'user_id' => '1', 'product_id' => '18', 'buys' => '26', 'shop_id' => '3'],
['quantity' => '26', 'price' => '295000', 'discount' => '0', 'user_id' => '1', 'product_id' => '19', 'buys' => '26', 'shop_id' => '3'],
['quantity' => '19', 'price' => '295000', 'discount' => '0', 'user_id' => '1', 'product_id' => '20', 'buys' => '19', 'shop_id' => '3'],
['quantity' => '29', 'price' => '265000', 'discount' => '0', 'user_id' => '1', 'product_id' => '21', 'buys' => '29', 'shop_id' => '1'],
['quantity' => '42', 'price' => '199000', 'discount' => '0', 'user_id' => '3', 'product_id' => '22', 'buys' => '42', 'shop_id' => '3'],
['quantity' => '32', 'price' => '455000', 'discount' => '400000', 'user_id' => '4', 'product_id' => '23', 'buys' => '32', 'shop_id' => '2'],
['quantity' => '37', 'price' => '169000', 'discount' => '0', 'user_id' => '2', 'product_id' => '24', 'buys' => '37', 'shop_id' => '1'],
['quantity' => '25', 'price' => '169000', 'discount' => '0', 'user_id' => '1', 'product_id' => '25', 'buys' => '25', 'shop_id' => '2'],
['quantity' => '20', 'price' => '179000', 'discount' => '0', 'user_id' => '3', 'product_id' => '26', 'buys' => '20', 'shop_id' => '3'],
['quantity' => '15', 'price' => '159000', 'discount' => '145000', 'user_id' => '1', 'product_id' => '27', 'buys' => '15', 'shop_id' => '1'],
['quantity' => '23', 'price' => '259000', 'discount' => '0', 'user_id' => '4', 'product_id' => '28', 'buys' => '23', 'shop_id' => '2'],
['quantity' => '34', 'price' => '199000', 'discount' => '185000', 'user_id' => '2', 'product_id' => '29', 'buys' => '34', 'shop_id' => '1'],
['quantity' => '13', 'price' => '279000', 'discount' => '270000', 'user_id' => '2', 'product_id' => '30', 'buys' => '13', 'shop_id' => '2'],
['quantity' => '14', 'price' => '329000', 'discount' => '0', 'user_id' => '3', 'product_id' => '31', 'buys' => '14', 'shop_id' => '3'],
['quantity' => '33', 'price' => '310000', 'discount' => '300000', 'user_id' => '4', 'product_id' => '32', 'buys' => '33', 'shop_id' => '2'],
['quantity' => '25', 'price' => '195000', 'discount' => '20', 'user_id' => '4', 'product_id' => '33', 'buys' => '25', 'shop_id' => '1'],
['quantity' => '21', 'price' => '350000', 'discount' => '0', 'user_id' => '2', 'product_id' => '34', 'buys' => '21', 'shop_id' => '3'],
['quantity' => '23', 'price' => '175000', 'discount' => '17000', 'user_id' => '3', 'product_id' => '35', 'buys' => '23', 'shop_id' => '2'],
['quantity' => '11', 'price' => '145000', 'discount' => '140000', 'user_id' => '1', 'product_id' => '36', 'buys' => '11', 'shop_id' => '3'],
['quantity' => '32', 'price' => '215000', 'discount' => '0', 'user_id' => '4', 'product_id' => '37', 'buys' => '32', 'shop_id' => '2'],
['quantity' => '31', 'price' => '115000', 'discount' => '0', 'user_id' => '3', 'product_id' => '38', 'buys' => '31', 'shop_id' => '3'],
['quantity' => '27', 'price' => '850000', 'discount' => '0', 'user_id' => '2', 'product_id' => '39', 'buys' => '27', 'shop_id' => '3'],
['quantity' => '7', 'price' => '260000', 'discount' => '0', 'user_id' => '3', 'product_id' => '40', 'buys' => '7', 'shop_id' => '2'],
['quantity' => '10', 'price' => '180000', 'discount' => '20', 'user_id' => '3', 'product_id' => '41', 'buys' => '10', 'shop_id' => '1'],
['quantity' => '7', 'price' => '220000', 'discount' => '0', 'user_id' => '4', 'product_id' => '42', 'buys' => '7', 'shop_id' => '1'],
['quantity' => '20', 'price' => '140000', 'discount' => '138000', 'user_id' => '3', 'product_id' => '43', 'buys' => '20', 'shop_id' => '3'],
['quantity' => '16', 'price' => '120000', 'discount' => '115000', 'user_id' => '2', 'product_id' => '44', 'buys' => '16', 'shop_id' => '1'],
['quantity' => '32', 'price' => '245000', 'discount' => '0', 'user_id' => '1', 'product_id' => '45', 'buys' => '32', 'shop_id' => '2'],
['quantity' => '32', 'price' => '350000', 'discount' => '325000', 'user_id' => '1', 'product_id' => '46', 'buys' => '32', 'shop_id' => '3'],

]);

}
}
Loading