質問編集履歴
2
モデルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,6 +118,120 @@
|
|
118
118
|
|
119
119
|
```
|
120
120
|
|
121
|
+
addressモデル
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
<?php
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
namespace App;
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
use Illuminate\Database\Eloquent\Model;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
class Address extends Model
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
//
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
protected $fillable = [
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
name
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
];
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
Userモデル
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
<?php
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
namespace App;
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
use Illuminate\Foundation\Auth\User as Authenticatable;
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
class User extends Authenticatable
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
/**
|
184
|
+
|
185
|
+
* The attributes that are mass assignable.
|
186
|
+
|
187
|
+
*
|
188
|
+
|
189
|
+
* @var array
|
190
|
+
|
191
|
+
*/
|
192
|
+
|
193
|
+
protected $fillable = [
|
194
|
+
|
195
|
+
'name', 'email', 'password',
|
196
|
+
|
197
|
+
];
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
/**
|
202
|
+
|
203
|
+
* The attributes excluded from the model's JSON form.
|
204
|
+
|
205
|
+
*
|
206
|
+
|
207
|
+
* @var array
|
208
|
+
|
209
|
+
*/
|
210
|
+
|
211
|
+
protected $hidden = [
|
212
|
+
|
213
|
+
'password', 'remember_token',
|
214
|
+
|
215
|
+
];
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
public function address(){
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
return $this->hasOne('App\Address');
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
```
|
234
|
+
|
121
235
|
|
122
236
|
|
123
237
|
|
1
マイグレーションファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,6 +44,82 @@
|
|
44
44
|
|
45
45
|
```
|
46
46
|
|
47
|
+
addressマイグレーションファイル
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
<?php
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
use Illuminate\Database\Schema\Blueprint;
|
58
|
+
|
59
|
+
use Illuminate\Database\Migrations\Migration;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
class CreateAddressesTable extends Migration
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
/**
|
68
|
+
|
69
|
+
* Run the migrations.
|
70
|
+
|
71
|
+
*
|
72
|
+
|
73
|
+
* @return void
|
74
|
+
|
75
|
+
*/
|
76
|
+
|
77
|
+
public function up()
|
78
|
+
|
79
|
+
{
|
80
|
+
|
81
|
+
Schema::create('addresses', function (Blueprint $table) {
|
82
|
+
|
83
|
+
$table->increments('id');
|
84
|
+
|
85
|
+
$table->integer('user_id')->unsigned()->nullable();
|
86
|
+
|
87
|
+
$table->string('name');
|
88
|
+
|
89
|
+
$table->timestamps();
|
90
|
+
|
91
|
+
});
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
/**
|
98
|
+
|
99
|
+
* Reverse the migrations.
|
100
|
+
|
101
|
+
*
|
102
|
+
|
103
|
+
* @return void
|
104
|
+
|
105
|
+
*/
|
106
|
+
|
107
|
+
public function down()
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
Schema::drop('addresses');
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
|
122
|
+
|
47
123
|
|
48
124
|
|
49
125
|
エラー:
|