質問編集履歴
2
改行
title
CHANGED
File without changes
|
body
CHANGED
@@ -42,19 +42,138 @@
|
|
42
42
|
###マイグレーションファイル
|
43
43
|
|
44
44
|
```items
|
45
|
-
use Illuminate\Database\Migrations\Migration;
|
45
|
+
use Illuminate\Database\Migrations\Migration;
|
46
|
+
use Illuminate\Database\Schema\Blueprint;
|
47
|
+
use Illuminate\Support\Facades\Schema;
|
48
|
+
|
49
|
+
class CreateItemsTable extends Migration
|
50
|
+
{
|
51
|
+
/**
|
52
|
+
* Run the migrations.
|
53
|
+
*
|
54
|
+
* @return void
|
55
|
+
*/
|
56
|
+
public function up()
|
57
|
+
{
|
58
|
+
Schema::create('items', function (Blueprint $table) {
|
59
|
+
$table->bigIncrements('id');
|
60
|
+
$table->string('name', 50)->nullable(false);
|
61
|
+
$table->integer('price')->nullable(false);
|
62
|
+
$table->text('introduction')->nullable(false);
|
63
|
+
$table->integer('stock_amount')->nullable(false);
|
64
|
+
$table->integer('buy_amount')->nullable(false);
|
65
|
+
$table->timestamps();
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Reverse the migrations.
|
71
|
+
*
|
72
|
+
* @return void
|
73
|
+
*/
|
74
|
+
public function down()
|
75
|
+
{
|
76
|
+
Schema::dropIfExists('items');
|
77
|
+
}
|
46
78
|
```
|
47
79
|
|
48
80
|
```carts
|
49
|
-
use Illuminate\Database\Migrations\Migration;
|
81
|
+
use Illuminate\Database\Migrations\Migration;
|
82
|
+
use Illuminate\Database\Schema\Blueprint;
|
83
|
+
use Illuminate\Support\Facades\Schema;
|
84
|
+
|
85
|
+
class CreateCartsTable extends Migration
|
86
|
+
{
|
87
|
+
/**
|
88
|
+
* Run the migrations.
|
89
|
+
*
|
90
|
+
* @return void
|
91
|
+
*/
|
92
|
+
public function up()
|
93
|
+
{
|
94
|
+
Schema::create('carts', function (Blueprint $table) {
|
95
|
+
$table->bigIncrements('id');
|
96
|
+
$table->integer('item_id');
|
97
|
+
$table->integer('user_id');
|
98
|
+
$table->timestamps();
|
99
|
+
});
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Reverse the migrations.
|
104
|
+
*
|
105
|
+
* @return void
|
106
|
+
*/
|
107
|
+
public function down()
|
108
|
+
{
|
109
|
+
Schema::dropIfExists('carts');
|
110
|
+
}
|
50
111
|
```
|
51
112
|
|
52
113
|
```items追加分
|
53
|
-
use Illuminate\Database\Migrations\Migration;
|
114
|
+
use Illuminate\Database\Migrations\Migration;
|
115
|
+
use Illuminate\Database\Schema\Blueprint;
|
116
|
+
use Illuminate\Support\Facades\Schema;
|
117
|
+
|
118
|
+
class AddImgpathToItemsTable extends Migration
|
119
|
+
{
|
120
|
+
/**
|
121
|
+
* Run the migrations.
|
122
|
+
*
|
123
|
+
* @return void
|
124
|
+
*/
|
125
|
+
public function up()
|
126
|
+
{
|
127
|
+
Schema::table('items', function (Blueprint $table) {
|
128
|
+
//
|
129
|
+
$table->string('imgpath', '200')->nullable(false);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Reverse the migrations.
|
135
|
+
*
|
136
|
+
* @return void
|
137
|
+
*/
|
138
|
+
public function down()
|
139
|
+
{
|
140
|
+
Schema::table('items', function (Blueprint $table) {
|
141
|
+
//
|
142
|
+
});
|
143
|
+
}
|
54
144
|
```
|
55
145
|
|
56
146
|
```items追加分
|
57
|
-
use Illuminate\Database\Migrations\Migration;
|
147
|
+
use Illuminate\Database\Migrations\Migration;
|
148
|
+
use Illuminate\Database\Schema\Blueprint;
|
149
|
+
use Illuminate\Support\Facades\Schema;
|
150
|
+
|
151
|
+
class AddStockToItemsTable extends Migration
|
152
|
+
{
|
153
|
+
/**
|
154
|
+
* Run the migrations.
|
155
|
+
*
|
156
|
+
* @return void
|
157
|
+
*/
|
158
|
+
public function up()
|
159
|
+
{
|
160
|
+
Schema::table('items', function (Blueprint $table) {
|
161
|
+
//
|
162
|
+
$table->integer('stock')->nullable(false);
|
163
|
+
});
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Reverse the migrations.
|
168
|
+
*
|
169
|
+
* @return void
|
170
|
+
*/
|
171
|
+
public function down()
|
172
|
+
{
|
173
|
+
Schema::table('items', function (Blueprint $table) {
|
174
|
+
//
|
175
|
+
});
|
176
|
+
}
|
58
177
|
```
|
59
178
|
|
60
179
|
|
1
新しいコードを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,6 +39,26 @@
|
|
39
39
|
}
|
40
40
|
```
|
41
41
|
|
42
|
+
###マイグレーションファイル
|
43
|
+
|
44
|
+
```items
|
45
|
+
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateItemsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('items', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name', 50)->nullable(false); $table->integer('price')->nullable(false); $table->text('introduction')->nullable(false); $table->integer('stock_amount')->nullable(false); $table->integer('buy_amount')->nullable(false); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('items'); }
|
46
|
+
```
|
47
|
+
|
48
|
+
```carts
|
49
|
+
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateCartsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('carts', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('item_id'); $table->integer('user_id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('carts'); }
|
50
|
+
```
|
51
|
+
|
52
|
+
```items追加分
|
53
|
+
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class AddImgpathToItemsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('items', function (Blueprint $table) { // $table->string('imgpath', '200')->nullable(false); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('items', function (Blueprint $table) { // }); }
|
54
|
+
```
|
55
|
+
|
56
|
+
```items追加分
|
57
|
+
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class AddStockToItemsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('items', function (Blueprint $table) { // $table->integer('stock')->nullable(false); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('items', function (Blueprint $table) { // }); }
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
|
42
62
|
### 試したこと
|
43
63
|
|
44
64
|
where句を用いて情報を取得して、それをcount関数で数えてあげればいいのかなと単純な考えで思考をしてみました。
|