Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee86f94

Browse files
authoredDec 16, 2018
Merge pull request #22 from yuuis/feature/add-categorized-furnitures
add association and seeder
2 parents db925a2 + 456ba3a commit ee86f94

File tree

5 files changed

+166
-2
lines changed

5 files changed

+166
-2
lines changed
 

‎app/Http/Models/Furnitures.php

+5
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ public function images()
2020
{
2121
return $this->hasMany('App\Http\Models\FurnitureImage');
2222
}
23+
24+
public function tag()
25+
{
26+
return $this->belongsTo('App\Http\Models\Tag');
27+
}
2328
}

‎app/Http/Models/Tag.php

+32-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,36 @@
66

77
class Tag extends Model
88
{
9-
//
9+
/**
10+
* Run the database seeds.
11+
*
12+
* @return void
13+
*/
14+
public function run()
15+
{
16+
DB::table("tags")->insert([
17+
"name" => "ベッド"
18+
]);
19+
DB::table("tags")->insert([
20+
"name" => "チェア"
21+
]);
22+
DB::table("tags")->insert([
23+
"name" => "デスク"
24+
]);
25+
DB::table("tags")->insert([
26+
"name" => "ソファ"
27+
]);
28+
DB::table("tags")->insert([
29+
"name" => "テーブル"
30+
]);
31+
DB::table("tags")->insert([
32+
"name" => "冷蔵庫"
33+
]);
34+
DB::table("tags")->insert([
35+
"name" => "レンジ"
36+
]);
37+
DB::table("tags")->insert([
38+
"name" => "洗濯機"
39+
]);
40+
}
1041
}

‎database/seeds/FurnitureCategoryTableSeeder.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@ class FurnitureCategoryTableSeeder extends Seeder
1212
public function run()
1313
{
1414
DB::table("furniture_categories")->insert([
15-
"name" => "ベッド",
15+
"name" => "ベッド"
16+
]);
17+
DB::table("furniture_categories")->insert([
18+
"name" => "チェア"
19+
]);
20+
DB::table("furniture_categories")->insert([
21+
"name" => "デスク"
22+
]);
23+
DB::table("furniture_categories")->insert([
24+
"name" => "ソファ"
25+
]);
26+
DB::table("furniture_categories")->insert([
27+
"name" => "テーブル"
28+
]);
29+
DB::table("furniture_categories")->insert([
30+
"name" => "冷蔵庫"
31+
]);
32+
DB::table("furniture_categories")->insert([
33+
"name" => "レンジ"
34+
]);
35+
DB::table("furniture_categories")->insert([
36+
"name" => "洗濯機"
1637
]);
1738
}
1839
}

‎database/seeds/FurnitureImageTableSeeder.php

+33
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,38 @@ public function run()
4343
"image_path" => "https://www.komeri.com/images/goods/014/009/49/1400949.jpg",
4444
"furnitures_id" => 8,
4545
]);
46+
47+
DB::table("furniture_images")->insert([
48+
"image_path" => "https://shopping.c.yimg.jp/lib/stepone2008/m-0001616_1.jpg",
49+
"furnitures_id" => 9,
50+
]);
51+
DB::table("furniture_images")->insert([
52+
"image_path" => "https://rr.img.naver.jp/mig?src=http%3A%2F%2Fimgcc.naver.jp%2Fkaze%2Fmission%2FUSER%2F20150906%2F70%2F7475700%2F23%2F200x200x98e5d72fb418d88bfbce89f1.jpg%2F300%2F600&twidth=300&theight=600&qlt=80&res_format=jpg&op=r",
53+
"furnitures_id" => 10,
54+
]);
55+
DB::table("furniture_images")->insert([
56+
"image_path" => "https://askul.c.yimg.jp/img/product/3L1/9671187_3L1.jpg",
57+
"furnitures_id" => 11,
58+
]);
59+
DB::table("furniture_images")->insert([
60+
"image_path" => "http://www.livinghouse-store.jp/images/detailed/16/IMG_3198.jpg",
61+
"furnitures_id" => 12,
62+
]);
63+
DB::table("furniture_images")->insert([
64+
"image_path" => "https://i.pinimg.com/564x/62/fa/f4/62faf4cd196d5fc08ec13ab56259daa4.jpg",
65+
"furnitures_id" => 13,
66+
]);
67+
DB::table("furniture_images")->insert([
68+
"image_path" => "https://image.biccamera.com/img/00000003731208_A01.jpg?sr.dw=600&sr.jqh=60&sr.dh=600&sr.mat=1",
69+
"furnitures_id" => 14,
70+
]);
71+
DB::table("furniture_images")->insert([
72+
"image_path" => "https://images-na.ssl-images-amazon.com/images/I/417Ez7TJaXL._SY355_.jpg",
73+
"furnitures_id" => 15,
74+
]);
75+
DB::table("furniture_images")->insert([
76+
"image_path" => "https://www.komeri.com/images/goods/014/009/49/1400949.jpg",
77+
"furnitures_id" => 16,
78+
]);
4679
}
4780
}

‎database/seeds/FurnitureTableSeeder.php

+74
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,79 @@ public function run()
8383
"length" => 50,
8484
"furniture_category_id" => 8
8585
]);
86+
87+
DB::table("furnitures")->insert([
88+
"name" => "白いシングルベッド",
89+
"purchase_price" => 15000,
90+
"rental_price" => 1200,
91+
"height" => 50,
92+
"width" => 200,
93+
"length" => 150,
94+
"furniture_category_id" => 1
95+
]);
96+
DB::table("furnitures")->insert([
97+
"name" => "白いチェア",
98+
"purchase_price" => 3000,
99+
"rental_price" => 300,
100+
"height" => 100,
101+
"width" => 50,
102+
"length" => 50,
103+
"furniture_category_id" => 2
104+
]);
105+
DB::table("furnitures")->insert([
106+
"name" => "L字デスク",
107+
"purchase_price" => 12000,
108+
"rental_price" => 560,
109+
"height" => 50,
110+
"width" => 150,
111+
"length" => 50,
112+
"furniture_category_id" => 3
113+
]);
114+
DB::table("furnitures")->insert([
115+
"name" => "2人掛けソファ",
116+
"purchase_price" => 8000,
117+
"rental_price" => 400,
118+
"height" => 50,
119+
"width" => 130,
120+
"length" => 40,
121+
"furniture_category_id" => 4
122+
]);
123+
DB::table("furnitures")->insert([
124+
"name" => "木製ローテーブル",
125+
"purchase_price" => 4000,
126+
"rental_price" => 400,
127+
"height" => 30,
128+
"width" => 40,
129+
"length" => 40,
130+
"furniture_category_id" => 5
131+
]);
132+
133+
DB::table("furnitures")->insert([
134+
"name" => "P社製冷蔵庫",
135+
"purchase_price" => 10000,
136+
"rental_price" => 560,
137+
"height" => 150,
138+
"width" => 50,
139+
"length" => 50,
140+
"furniture_category_id" => 6
141+
]);
142+
DB::table("furnitures")->insert([
143+
"name" => "P社製電子レンジ",
144+
"purchase_price" => 4000,
145+
"rental_price" => 230,
146+
"height" => 30,
147+
"width" => 40,
148+
"length" => 40,
149+
"furniture_category_id" => 7
150+
]);
151+
DB::table("furnitures")->insert([
152+
"name" => "P社製洗濯機",
153+
"purchase_price" => 20000,
154+
"rental_price" => 1200,
155+
"height" => 80,
156+
"width" => 50,
157+
"length" => 50,
158+
"furniture_category_id" => 8
159+
]);
86160
}
87161
}

0 commit comments

Comments
 (0)
Please sign in to comment.