質問編集履歴

2

ソースコードの提示

2018/07/12 07:19

投稿

rx179mk5
rx179mk5

スコア33

test CHANGED
File without changes
test CHANGED
@@ -38,7 +38,7 @@
38
38
 
39
39
  ※以下、コーディングした内容です。
40
40
 
41
- 1. マイグレーションファイルの作成、マイグレートの実行
41
+ マイグレーションファイルの作成、マイグレートの実行
42
42
 
43
43
  $ php artisan make:migration add_column_softDeletes_users_table --table=users
44
44
 
@@ -110,7 +110,7 @@
110
110
 
111
111
 
112
112
 
113
- 2. モデルの作成
113
+ モデルの作成
114
114
 
115
115
  $ php artisan make:model Models/Users
116
116
 
@@ -146,10 +146,10 @@
146
146
 
147
147
 
148
148
 
149
- 3. 下記SQL文にて、ユーザをソフトデリートしました。
149
+ 下記SQL文にて、ユーザをソフトデリートしました。
150
150
 
151
151
  > update users set deleted_at = '2018-07-12 01:03:26' where id = 1;
152
152
 
153
153
 
154
154
 
155
- 4. 前項でソフトデリートしたユーザでログインを試みるとログインできてしまいます。
155
+ 前項でソフトデリートしたユーザでログインを試みるとログインできてしまいます。

1

ソースコードの提示

2018/07/12 07:19

投稿

rx179mk5
rx179mk5

スコア33

test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,123 @@
33
33
 
34
34
 
35
35
  以上、よろしくお願い致します。
36
+
37
+
38
+
39
+ ※以下、コーディングした内容です。
40
+
41
+ 1. マイグレーションファイルの作成、マイグレートの実行
42
+
43
+ $ php artisan make:migration add_column_softDeletes_users_table --table=users
44
+
45
+ $ view 2018_07_12_045301_add_column_soft_deletes_users_table.php
46
+
47
+ > <?php
48
+
49
+ >
50
+
51
+ > use Illuminate\Support\Facades\Schema;
52
+
53
+ > use Illuminate\Database\Schema\Blueprint;
54
+
55
+ > use Illuminate\Database\Migrations\Migration;
56
+
57
+ >
58
+
59
+ > class AddColumnSoftDeletesUsersTable extends Migration
60
+
61
+ > {
62
+
63
+ > /**
64
+
65
+ > * Run the migrations.
66
+
67
+ > *
68
+
69
+ > * @return void
70
+
71
+ > */
72
+
73
+ > public function up()
74
+
75
+ > {
76
+
77
+ > Schema::table('users', function (Blueprint $table) {
78
+
79
+ > $table->softDeletes();
80
+
81
+ > });
82
+
83
+ > }
84
+
85
+ >
86
+
87
+ > /**
88
+
89
+ > * Reverse the migrations.
90
+
91
+ > *
92
+
93
+ > * @return void
94
+
95
+ > */
96
+
97
+ > public function down()
98
+
99
+ > {
100
+
101
+ > Schema::table('users', function (Blueprint $table) {
102
+
103
+ > $table->dropColumn('deleted_at');
104
+
105
+ > });
106
+
107
+ > }
108
+
109
+ > }
110
+
111
+
112
+
113
+ 2. モデルの作成
114
+
115
+ $ php artisan make:model Models/Users
116
+
117
+ $ view Users.php
118
+
119
+ > <?php
120
+
121
+ >
122
+
123
+ > namespace App\Models;
124
+
125
+ >
126
+
127
+ > use Illuminate\Database\Eloquent\Model;
128
+
129
+ > use Illuminate\Database\Eloquent\SoftDeletes;
130
+
131
+ >
132
+
133
+ > class Users extends Model
134
+
135
+ > {
136
+
137
+ > use SoftDeletes;
138
+
139
+ >
140
+
141
+ > protected $table = 'users';
142
+
143
+ > protected $dates = ['deleted_at'];
144
+
145
+ > }
146
+
147
+
148
+
149
+ 3. 下記SQL文にて、ユーザをソフトデリートしました。
150
+
151
+ > update users set deleted_at = '2018-07-12 01:03:26' where id = 1;
152
+
153
+
154
+
155
+ 4. 前項でソフトデリートしたユーザでログインを試みるとログインできてしまいます。