質問編集履歴

2

migrationファイルを追加しました

2019/12/11 15:06

投稿

kotakeshi0923
kotakeshi0923

スコア28

test CHANGED
File without changes
test CHANGED
@@ -205,3 +205,175 @@
205
205
  }
206
206
 
207
207
  ```
208
+
209
+
210
+
211
+ <migration1>
212
+
213
+ ```
214
+
215
+ <?php
216
+
217
+
218
+
219
+ use Illuminate\Database\Migrations\Migration;
220
+
221
+ use Illuminate\Database\Schema\Blueprint;
222
+
223
+ use Illuminate\Support\Facades\Schema;
224
+
225
+
226
+
227
+ class CreateRpTableForRds extends Migration
228
+
229
+ {
230
+
231
+ /**
232
+
233
+ * Run the migrations.
234
+
235
+ *
236
+
237
+ * @return void
238
+
239
+ */
240
+
241
+ public function up()
242
+
243
+ {
244
+
245
+ Schema::create('rp', function (Blueprint $table) {
246
+
247
+ $table->bigIncrements('id');
248
+
249
+ $table->string('client_id');
250
+
251
+ $table->string('service_name');
252
+
253
+ $table->string('description')->nullable();
254
+
255
+ $table->string('oidc_login_redirect_url');
256
+
257
+ $table->string('oidc_logout_redirect_url');
258
+
259
+ $table->string('oidc_client_secret')->nullable();
260
+
261
+ $table->string('wifi_stadium_id')->nullable();
262
+
263
+ $table->string('wifi_home_club_cd')->nullable();
264
+
265
+ $table->boolean('enabled')->nullable();
266
+
267
+ $table->string('display_pattern')->nullable()->comment('"00": ミニマム、"01":標準、"02":フル');
268
+
269
+ $table->boolean('display_header_footer')->nullable()->comment('画面のヘッダ・フッタを表示/非表示');
270
+
271
+ $table->boolean('display_agreement_check')->nullable()->comment('規約同意チェックボックスの表示/非表示');
272
+
273
+ $table->string('login_button_pattern')->nullable()->comment('"00":標準、"01":メールアドレス');
274
+
275
+ $table->bigInteger('register_timestamp')->nullable(); // Unix Timestamp
276
+
277
+ $table->string('register_principal')->nullable();
278
+
279
+ $table->bigInteger('update_timestamp')->nullable(); // Unix Timestamp
280
+
281
+ $table->string('update_principal')->nullable();
282
+
283
+ });
284
+
285
+ }
286
+
287
+
288
+
289
+ /**
290
+
291
+ * Reverse the migrations.
292
+
293
+ *
294
+
295
+ * @return void
296
+
297
+ */
298
+
299
+ public function down()
300
+
301
+ {
302
+
303
+ Schema::dropIfExists('rp');
304
+
305
+ }
306
+
307
+ }
308
+
309
+ ```
310
+
311
+ <migration2>
312
+
313
+ ```
314
+
315
+ <?php
316
+
317
+
318
+
319
+ use Illuminate\Database\Migrations\Migration;
320
+
321
+ use Illuminate\Database\Schema\Blueprint;
322
+
323
+ use Illuminate\Support\Facades\Schema;
324
+
325
+
326
+
327
+ class AddSoftDeleteRpTableForRds extends Migration
328
+
329
+ {
330
+
331
+ /**
332
+
333
+ * Run the migrations.
334
+
335
+ *
336
+
337
+ * @return void
338
+
339
+ */
340
+
341
+ public function up()
342
+
343
+ {
344
+
345
+ Schema::table('rp', function (Blueprint $table) {
346
+
347
+ $table->softdeletes();
348
+
349
+ });
350
+
351
+ }
352
+
353
+
354
+
355
+ /**
356
+
357
+ * Reverse the migrations.
358
+
359
+ *
360
+
361
+ * @return void
362
+
363
+ */
364
+
365
+ public function down()
366
+
367
+ {
368
+
369
+ Schema::table('rp', function (Blueprint $table) {
370
+
371
+ $table->dropColumn('deleted_at');
372
+
373
+ });
374
+
375
+ }
376
+
377
+ }
378
+
379
+ ```

1

modelの全体をアップいたしました。

2019/12/11 15:06

投稿

kotakeshi0923
kotakeshi0923

スコア28

test CHANGED
File without changes
test CHANGED
@@ -44,19 +44,77 @@
44
44
 
45
45
  class RPController extends Controller
46
46
 
47
-
47
+ {
48
+
48
-
49
+ function index(Request $request)
50
+
51
+ {
52
+
53
+ if(isset($request->display_items)){
54
+
55
+ $paginate = $request->display_items;
56
+
57
+ }
58
+
59
+ else {
60
+
61
+ $paginate = 20;
62
+
63
+ }
64
+
65
+ if(isset($request->page)){
66
+
67
+ $page = $request->page;
68
+
69
+ } else {
70
+
49
- ...........
71
+ $page = 1;
72
+
50
-
73
+ }
74
+
51
-
75
+ $display_items = $paginate;
76
+
77
+
78
+
52
-
79
+ $page_params = array();
80
+
81
+ $page_params['size'] = 20;
82
+
83
+ $page_params['direction'] = "ASC";
84
+
85
+ $rp_info = \App\Library\Pz::getRP($page_params);
86
+
87
+
88
+
53
- $rp_clients = new RP();
89
+ $rp_clients = new RP();
54
-
90
+
55
- $rp_clients = $rp_clients->getRPClient(parameterA,parameterB);
91
+ $rp_clients = $rp_clients->getRPClient($rp_info[0],'client_id');
92
+
93
+
94
+
56
-
95
+ $total_count = count($rp_info[0]);
96
+
97
+
98
+
57
-
99
+ $start_record = ($page - 1) * $paginate + 1;
100
+
58
-
101
+ $end_record = ($page * $paginate >= count($rp_info) ) ? count($rp_info) : $page * $paginate;
102
+
103
+
104
+
59
- ...........
105
+ $pagination_params = [
106
+
107
+ "display_items" => $display_items,
108
+
109
+ ];
110
+
111
+
112
+
113
+ return view('rp/index', compact('rp_clients', 'start_record', 'end_record', 'total_count',
114
+
115
+ 'display_items', 'pagination_params'));
116
+
117
+ }
60
118
 
61
119
  ```
62
120
 
@@ -68,23 +126,63 @@
68
126
 
69
127
  namespace App\Model;
70
128
 
129
+
130
+
71
131
  use Illuminate\Database\Eloquent\Model;
72
132
 
73
133
  use Illuminate\Database\Eloquent\SoftDeletes;
74
134
 
135
+
136
+
75
137
  use Carbon\Carbon;
76
138
 
77
139
 
78
140
 
79
141
  class RP extends Model
80
142
 
81
-
143
+ {
82
-
144
+
83
- ............
145
+ use SoftDeletes;
146
+
147
+
148
+
84
-
149
+ protected $table = 'rp';
150
+
85
-
151
+ public $tableType = 'master';
152
+
153
+
154
+
86
-
155
+ protected $primaryKey = 'id';
156
+
157
+ protected $keyType = 'bigint';
158
+
159
+ public $incrementing = true;
160
+
161
+
162
+
163
+ protected $dates = ['deleted_at'];
164
+
165
+ protected $fillable = ['client_id', 'service_name', 'description',
166
+
167
+ 'oidc_login_redirect_url', 'oidc_logout_redirect_url',
168
+
169
+ 'oidc_client_secret', 'wifi_stadium_id', 'wifi_home_club_cd', 'enabled',
170
+
171
+ 'display_pattern', 'display_header_footer', 'display_agreement_check',
172
+
173
+ 'login_button_pattern', 'register_timestamp', 'register_principal',
174
+
175
+ 'update_timestamp', 'update_principal'];
176
+
177
+
178
+
179
+ // created_at, updated_at は DB の機能で自動更新する.
180
+
181
+ public $timestamps = false;
182
+
183
+
184
+
87
- public function getRPClient($parentAry, $target){
185
+ public function getRPClient($parentAry, $target){
88
186
 
89
187
  foreach($parentAry as $childAry){
90
188
 
@@ -104,4 +202,6 @@
104
202
 
105
203
  }
106
204
 
205
+ }
206
+
107
- ```
207
+ ```