Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel在数据保存后重定向到视图_Php_Laravel 5.3 - Fatal编程技术网

Php Laravel在数据保存后重定向到视图

Php Laravel在数据保存后重定向到视图,php,laravel-5.3,Php,Laravel 5.3,我已经创建了一个表单,并使用Laravel5.3成功地将表单值插入数据库。但在提交数据后,我无法重定向到查看页面,它显示一个空白页面。下面是我的代码 Viewstore.blade.php: ControllerTesting.php: 模型curd.php: 从模型提交表单后,我不知道如何重定向。请帮助我不要在模型上重定向。将return redirect->移回存储方法 您正在模型中重定向。这是不可接受的。应该在控制器中处理。@MU谢谢,我收到了 {{Form::open(array('ac

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

Viewstore.blade.php:

ControllerTesting.php:

模型curd.php:


从模型提交表单后,我不知道如何重定向。请帮助我不要在模型上重定向。将return redirect->移回存储方法

您正在模型中重定向。这是不可接受的。应该在控制器中处理。@MU谢谢,我收到了
{{Form::open(array('action' => 'Testing@store', 'method' => 'post'))}}

<div class="form-group">
    {!! Form::label('title', 'Title:', ['class' => 'control-label']) !!}
    {!! Form::text('title', null, ['class' => 'form-control']) !!}
</div>

    <div class="form-group">
        {!! Form::label('description', 'Description:', ['class' => 'control-label']) !!}
        {!! Form::textarea('description', null, ['class' => 'form-control']) !!}
    </div>

    {!! Form::submit('Submitform', ['class' => 'btn btn-primary']) !!}

    {!! Form::close() !!}
<?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);


    }
}
<?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();


    }
}