質問編集履歴

3

2019/03/20 06:04

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
File without changes

2

自己解決削除

2019/03/20 06:04

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Laravel5 エラー「Undefined variable: 〇〇"」に悩まされる朝
1
+ 自己解決削(Swiftで困ったこと
test CHANGED
@@ -1,547 +1,37 @@
1
- ### 前提・実現したいこと
1
+ g自己解決削除
2
2
 
3
- まず前提としてPHP,Laravel初心者です。
3
+ Swiftで困ったこ「このバグを直してください」
4
+
5
+ 記事タイトルの良い例
4
6
 
5
7
 
6
8
 
7
- PHP)教室アカウントの修正や削除がきるページ作成るのですが、
9
+ 「LocalNotification通知時間指定
8
10
 
11
+ 「配列の要素数をある数以上にしようとするとエラーが出る」
12
+
9
- なかなかエラーが解消されず質問させていただきした。
13
+ 「md_send_mailのエラーで困っています」
14
+
15
+ 本文の書き方
10
16
 
11
17
 
12
18
 
13
- 希望ページは下記になります。
19
+ 5つの要点を抑えると回答が得られやすくなります。
14
-
15
- ![イメージ説明](3624bc0e7e920438731cd1682d4abfd1.png)
16
20
 
17
21
 
18
22
 
19
- 簡単なページ機能を説明する
23
+ 前提・実現したいこ
20
24
 
21
- (上記イメージの説明)
22
-
23
- ・塾 →前ページで選択した塾コードと名前を保持してきて、上記ページに表示だけさせる
24
-
25
- ・教室コード →塾と同じで前ページで選択した修正したい教室のコードを保持表示
26
-
27
- ・教室名 →現状の教室名を表示させ、上書き更新できるようにする
28
-
29
- ・チェックボタン →チェックボタンクリックるとそ下のパスワードを変更できるようにする
25
+ (例)PHP(CakePHP)で●●なシステム作っていま。 ■■な機能を実装したいのですがうまく動ません。
30
26
 
31
27
 
32
28
 
33
- 以上となります。
29
+ 発生している問題・エラーメッセージ
34
30
 
31
+ 問題が発生するまでの流れ・手順
35
32
 
33
+ ソースコード
36
34
 
37
- おそらくタイトルエラー以外にもダメなポイントがあるかと感じておりますが、
35
+ 問題の発生した環境
38
36
 
39
- のジャッジができないのです。。。
37
+ (例)言語・ライブラリバーョン
40
-
41
- お力をお貸しください。
42
-
43
-
44
-
45
- ### 発生している問題・エラーメッセージ
46
-
47
-
48
-
49
- ```ここに言語を入力
50
-
51
-
52
-
53
- Arguments
54
-
55
- "Undefined variable: sch_code"
56
-
57
- Environment & details:
58
-
59
- ```
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
- ### Controller (エラー内容該当部分と思われる
68
-
69
- ```ここに言語を入力
70
-
71
- namespace App\Http\Controllers;
72
-
73
-
74
-
75
- use \Request;
76
-
77
- use Illuminate\Support\Facades\DB;
78
-
79
- use App\Models\MClass;
80
-
81
- use App\Models\MSchool;
82
-
83
- use Hash;
84
-
85
- use Validator;
86
-
87
- use App\Http\Requests\KmasterCorrectionRequest;
88
-
89
-
90
-
91
- class KmasterCorrectionController extends Controller {
92
-
93
- /**
94
-
95
- * 教室マスタ・修正画面を表示する。
96
-
97
- *
98
-
99
- * @param cls_code 教室コード
100
-
101
- * @return view
102
-
103
- */
104
-
105
- public function index() {
106
-
107
-
108
-
109
- // 教室マスタの取得
110
-
111
- $kmaster = MClass::where([['m_class.sch_code', $sch_code],['cls_code',$cls_code]])->first();//first()
112
-
113
- // ->where('sch_code', 1)->first();
114
-
115
- var_dump($kmaster );
116
-
117
- var_dump($sch_code);
118
-
119
- return view('kmasterCorrection', ['kmaster' => $kmaster]);
120
-
121
- }
122
-
123
-
124
-
125
- /**
126
-
127
- * 教室マスタ修正・削除処理を行う。
128
-
129
- *
130
-
131
- * @param request
132
-
133
- * @return redirect
134
-
135
- */
136
-
137
- public function correction(KmasterCorrectionRequest $request) {
138
-
139
- //$cls_code = null;//エラー回避の為の初期化Notice: Undefined variable:
140
-
141
- //$sch_code = null;//エラー回避の為の初期化Notice: Undefined variable:
142
-
143
-
144
-
145
- // 教室マスタ
146
-
147
- $m_class = MClass::where('sch_code', $request->sch_code)->first();
148
-
149
- if (!$m_class){
150
-
151
- // 教室マスタが存在しない
152
-
153
- return back()->withInput()->withErrors(['sch_code' => "該当の教室マスタが存在しません。"]);
154
-
155
- }
156
-
157
-
158
-
159
-
160
-
161
- //修正ボタン押下時
162
-
163
- if (Request::input('update')) {
164
-
165
- // チェックボックス
166
-
167
- $kpchange = Request::input('kpchange');
168
-
169
- // チェックありの場合
170
-
171
- if (!empty($kpchange)) {
172
-
173
- //教室アカウントパスワードのバリデーション追加
174
-
175
- $validator = Validator::make($request->all(), [
176
-
177
- 'update_password' => 'required|alpha_num|confirmed',
178
-
179
- 'update_password_confirmation' => 'required'
180
-
181
- ]);
182
-
183
- if ($validator->fails()) {
184
-
185
- return back()->withInput()->withErrors($validator);
186
-
187
- }
188
-
189
- }
190
-
191
-
192
-
193
- // 教室マスタ(更新前)
194
-
195
- $m_class = MClass::where('sch_code', $request->sch_code)->first();
196
-
197
- // 更新する値を代入
198
-
199
- $m_class->sch_code = $request->sch_code; //塾コード塾名
200
-
201
- $m_class->cls_code = $request->cls_code; //教室コード
202
-
203
- $m_class->name = $request->name; //教室名
204
-
205
- // パスワードをハッシュ化
206
-
207
- $m_class->password = Hash::make($request->update_password);
208
-
209
- // 教室マスタの更新
210
-
211
- $m_class->save();
212
-
213
- }
214
-
215
-
216
-
217
- // 削除ボタン押下時
218
-
219
- if (Request::input('delete')) {
220
-
221
- // 削除処理
222
-
223
- $m_class->delete();
224
-
225
- }
226
-
227
-
228
-
229
- // 一覧画面へリダイレクト
230
-
231
- return redirect('kmasterList');
232
-
233
- }
234
-
235
-
236
-
237
- }
238
-
239
- ```
240
-
241
- ### Blade
242
-
243
- ```
244
-
245
- @extends('layout.common')
246
-
247
-
248
-
249
- @section('title', '教室マスタ・修正')
250
-
251
- @section('keywords', 'A,B,C')
252
-
253
- @section('description', '説明文')
254
-
255
- @section('pageCss')
256
-
257
- @endsection
258
-
259
-
260
-
261
- @include('layout.head')
262
-
263
-
264
-
265
- @include('layout.header')
266
-
267
-
268
-
269
- @section('content')
270
-
271
- <div id="site_content" class="kmaster">
272
-
273
- <div id="content">
274
-
275
- <h1>教室マスタ・修正</h1>
276
-
277
- <div id="km_correction" class="correction">
278
-
279
- @if(count($errors) > 0)
280
-
281
- <div class="alert alert-danger">
282
-
283
- <ul>
284
-
285
- @foreach($errors->all() as $error)
286
-
287
- <li>{{ $error}}</li>
288
-
289
- @endforeach
290
-
291
- </ul>
292
-
293
- </div>
294
-
295
- @endif
296
-
297
- <form method="post" action="{{route('kmasterCorrection.correction')}}">
298
-
299
- <!-- CSRF保護 -->
300
-
301
- @csrf
302
-
303
- <table>
304
-
305
- <tr>
306
-
307
- <td>
308
-
309
- <p>塾</p>
310
-
311
- </td>
312
-
313
- <td>
314
-
315
- <p>
316
-
317
- {{ $kmaster->sch_code }}
318
-
319
- </p>
320
-
321
- </td>
322
-
323
- </tr>
324
-
325
- <tr>
326
-
327
- <td>
328
-
329
- <p>教室コード</p>
330
-
331
- </td>
332
-
333
- <td>
334
-
335
- <p>
336
-
337
- {{ $kmaster->cls_code }}
338
-
339
- <input type="hidden" name="cls_code" value="{{ $kmaster->cls_code }}">
340
-
341
- </p>
342
-
343
- </td>
344
-
345
- </tr>
346
-
347
- <tr>
348
-
349
- <td>
350
-
351
- <p>教室名</p>
352
-
353
- </td>
354
-
355
- <td>
356
-
357
- <p>
358
-
359
- <input class="cell" type="text" name="name" value="{{ old('name', $kmaster->name) }}">
360
-
361
- </p>
362
-
363
- </td>
364
-
365
- </tr>
366
-
367
- <tr>
368
-
369
- <td>
370
-
371
- <label>
372
-
373
- <input type="checkbox" name="kpchange" id="kpchange" class="checkbox"><span class="ctext">教室アカウントとのパスワードを変更</span>
374
-
375
- </label>
376
-
377
- </td>
378
-
379
- </tr>
380
-
381
- <tr>
382
-
383
- <td>
384
-
385
- <p>教室アカウントパスワード</p>
386
-
387
- </td>
388
-
389
- <td>
390
-
391
- <p>
392
-
393
- <input id="pass" class="cell" type="password" name="update_password" value="">
394
-
395
- </p>
396
-
397
- </td>
398
-
399
- </tr>
400
-
401
- <tr>
402
-
403
- <td>
404
-
405
- <p>教室アカウントパスワード(確認)</p>
406
-
407
- </td>
408
-
409
- <td>
410
-
411
- <p>
412
-
413
- <input id="pass_confirmation" class="cell" type="password" name="update_password_confirmation" value="">
414
-
415
- </p>
416
-
417
- </td>
418
-
419
- </tr>
420
-
421
- </table>
422
-
423
- <div class="buttons">
424
-
425
- <p class="cell"><input class="button bulu" type="submit" name="update" value="修正"></p>
426
-
427
- <p class="cell"><input class="button bulu delete_dialog" type="submit" name="delete" value="削除" onclick='return confirm("削除してもよろしいですか?");'></p>
428
-
429
- <a href="{{ route('kmasterList.index') }}" class="cell"><p class="button green">一覧に戻る</p></a>
430
-
431
- </div>
432
-
433
- </form>
434
-
435
- </div>
436
-
437
- </div>
438
-
439
- </div>
440
-
441
-
442
-
443
- @endsection
444
-
445
-
446
-
447
- @include('layout.footer')
448
-
449
- ```
450
-
451
-
452
-
453
- ### こちらも重要Request
454
-
455
- ```ここに言語を入力
456
-
457
- <?php
458
-
459
-
460
-
461
- namespace App\Http\Requests;
462
-
463
-
464
-
465
- use Illuminate\Foundation\Http\FormRequest;
466
-
467
-
468
-
469
- class KmasterCorrectionRequest extends FormRequest
470
-
471
- {
472
-
473
- /**
474
-
475
- * Determine if the user is authorized to make this request.
476
-
477
- *
478
-
479
- * @return bool
480
-
481
- */
482
-
483
- public function authorize()
484
-
485
- {
486
-
487
- return true;
488
-
489
- }
490
-
491
-
492
-
493
- /**
494
-
495
- * Get the validation rules that apply to the request.
496
-
497
- *
498
-
499
- * @return array
500
-
501
- */
502
-
503
- public function rules()
504
-
505
- {
506
-
507
- return [
508
-
509
- 'cls_code'=>'required|digits_between:1,4|numeric',
510
-
511
- 'kname' =>'string|max:20'
512
-
513
-
514
-
515
- ];
516
-
517
- }
518
-
519
-
520
-
521
-
522
-
523
- public function attributes() {
524
-
525
- return [
526
-
527
- 'cls_code'=>'教室コード',
528
-
529
- 'kname'=>'教室名'
530
-
531
- ];
532
-
533
- }
534
-
535
- }
536
-
537
- ```
538
-
539
-
540
-
541
- ### 補足情報(FW/ツールのバージョンなど)
542
-
543
- laravel5.7
544
-
545
- PHP7.3
546
-
547
- Mysql5.7

1

タイトル修正

2019/03/20 00:11

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Laravel5 エラー「Undefined variable: sch_code"」に悩まされる朝
1
+ Laravel5 エラー「Undefined variable: 〇〇"」に悩まされる朝
test CHANGED
File without changes