Laravel重定向数据保存后查看

时间:2016-12-15 11:43:29

标签: php laravel-5.3

我已经使用laravel 5.3创建了一个表单并将表单值插入数据库。但提交数据后,我无法重定向到查看页面,它显示一个空白页面。下面是我的代码

查看(store.blade.php):

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\curd;
class testing extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('pages.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

      $storeform=new curd();
      $storeform->savemodel($request);


    }
}

控制器(Testing.php):

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;
class curd extends Model
{
    public function savemodel($request)
    {
     // $request->input('title');
     DB::table('tset')->insert(
             ['heading' => $request->input('title'),'description'=>$request->input('description')]
             ); 

      return redirect()->back();


    }
}

型号(curd.php):

{{range $response := .result}}
    {{$old := "FALSE"}}
    {{range $seat := $response.SeatList}}
       {{$old}} -------
       {{if ne $old $seat.Row}} {{$old := $seat.Row}} {{$old}} ------- {{end}}
    {{end}}
{{end}}

我不知道如何在从模型提交表单后重定向。请帮助我

1 个答案:

答案 0 :(得分:1)

不要重新定位您的模型。将return redirect() - &gt; back()返回到store-method。