laravelを学習していたのですが、postした際に、ページが表示できない問題が発生しています。
以下は、ルート情報を記載した、「web.php」です
php
1<?php 2 3/* 4|-------------------------------------------------------------------------- 5| Web Routes 6|-------------------------------------------------------------------------- 7| 8| Here is where you can register web routes for your application. These 9| routes are loaded by the RouteServiceProvider within a group which 10| contains the "web" middleware group. Now create something great! 11| 12*/ 13 14 15// Route::post('hello','HelloContoroller@post'); 16 17//use App\Http\Middleware\HelloMiddleware; 18 19Route::get('hello/add','HelloController@add'); 20Route::post('hello/add','HelloController@create'); 21 22// Route::get('hello/other','HelloController@other'); 23
以下はコントローラ部分の「HelloController.php」です
php
1<?php 2 3namespace App\Http\Controllers; 4 5use Illuminate\Http\Request; 6use Illuminate\Http\Response; 7use App\Http\Requests\HelloRequest; 8use Validator; 9use Illuminate\Support\Facades\DB; 10 11 12class HelloController extends Controller{ 13 14 public function index(Request $request) 15 { 16 17 18 $items = DB::select('select * from people'); 19 return view('hello.index',['items' => $items]); 20 21 } 22 23 public function post(Request $request) 24 25 { 26 $items = DB::select('select * from people'); 27 return view('hello.index',['items' => $items]); 28 29 } 30 public function add(Request $request) 31 { 32 return view('hello.add'); 33 } 34 35 public function create(Request $request) 36 { 37 $param = [ 38 'name' => $request->name, 39 'mail' => $request->mail, 40 'age' => $request->age, 41 ]; 42 43 DB::insert('insert into people (name, mail, age) values 44 (:name, :mail,:age)',$param); 45 return redirect('./hello'); 46 } 47 48 49 50 51} 52
下記はview部分である「add.blade.php」です
php
1@extends('layouts.helloapp') 2@section('title','Add') 3@section('menubar') 4 @parent 5 新規作成ページ 6@endsection 7 8@section('content') 9 <table> 10 <form action="/hello/add" method="post"> 11 {{ csrf_field() }} 12 <tr><th>name:</th><td><input type="text" name="name"></td></tr> 13 <tr><th>mail:</th><td><input type="text"></td></tr> 14 <tr><th>age: </th><td><input type="text" name="age"></td></tr> 15 <tr><th></th><td><input type="submit" value="send"></td></tr> 16 </form> 17 </table> 18 @endsection 19 20 @section('footer') 21 copyright 2017 tuyano. 22 @endsection
起きている問題としましては、/hello/addにgetアクセスした場合は、add.blade.phpが表示されるのですが、add.blade.phpからフォーム部分の入力値を空にしてpostした場合、「Maximum execution time of 30 seconds exceeded」となってしまい、画面が表示できません。
原因が分からない為、ご助言頂けましたら幸いです。
よろしくお願いします
以下は、タイムアウトした際のエラーログ(Connection.php)になります。
// To execute the statement, we'll simply call the callback, which will actually // run the SQL against the PDO connection. Then we can calculate the time it // took to execute and log the query SQL, bindings and time in our memory. try { $result = $callback($query, $bindings); } // If an exception occurs when attempting to run a query, we'll format the error // message to include the bindings with SQL, which will make this exception a // lot more helpful to the developer instead of just the database's errors. catch (Exception $e) { throw new QueryException( $query, $this->prepareBindings($bindings), $e ); } return $result; } /** * Log a query in the connection's query log. * * @param string $query * @param array $bindings * @param float|null $time * @return void */ public function logQuery($query, $bindings, $time = null) { $this->event(new QueryExecuted($query, $bindings, $time, $this)); Arguments "Maximum execution time of 30 seconds exceeded"