Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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_Laravel 5.2 - Fatal编程技术网

Php Laravel未过帐到数据库

Php Laravel未过帐到数据库,php,laravel,laravel-5.2,Php,Laravel,Laravel 5.2,代码中的某个地方有一个bug,我似乎找不到它,任何帮助都会很好。它是一个存储到数据库的简单表单 该应用程序使用的是laravel 5.2,所需的只是收集数据。当点击表单上的提交按钮时,什么都没有 路线 控制器只需要索引、创建和存储,这就是应用程序需要做的全部工作 <?php namespace App\Http\Controllers; use Request; use App\Http\Requests; use Data; use App\Http\Requests\DataReq

代码中的某个地方有一个bug,我似乎找不到它,任何帮助都会很好。它是一个存储到数据库的简单表单

该应用程序使用的是laravel 5.2,所需的只是收集数据。当点击表单上的提交按钮时,什么都没有

路线

控制器只需要索引、创建和存储,这就是应用程序需要做的全部工作

<?php

namespace App\Http\Controllers;

use Request;
use App\Http\Requests;
use Data;
use App\Http\Requests\DataRequest;
use Carbon\Carbon;

class PagesController extends Controller
{
    //Display Index
    public function index()
    {
        return view ('welcome');
    }

    public function create()
    {
        return view ('create');
    }

    //Store Articles from form
    public function store(DataRequest $request)
    {
        Data::create($request->all());
        return redirect('create')->with('message' , 'Form submitted');
    }


}

所以问题是评论中提到的

使用数据

使用App\DATA

和一些小的前端调整的混合


所有的都分类了,所以问题是评论中提到的

使用数据

使用App\DATA

和一些小的前端调整的混合


“全部排序”

页面是否会刷新,或者当您按下“提交”按钮时,页面是否会什么也不做?尝试在url{!!Form::open(['url'=>'/Form'])!!}中放置一个/。如果您将$request注销到laravel日志中,您是否获得了所需的所有数据?您确定此代码有效吗?您使用的名称空间不正确Data@MinaAbadir我相信数据文件的名称空间很好。。。但在PagesController中,它是错误的@莫比。。。应该是
use-App\Data
而不是
use-Data
@prateekkathal这就是我说的,他导入了错误的类。页面是否会刷新,或者当你按下submit时,页面是否会什么都不做?尝试在url{!!Form::open(['url'=>'/Form'])!!}中放置一个/。如果您将$request注销到laravel日志中,您是否获得了所需的所有数据?您确定此代码有效吗?您使用的名称空间不正确Data@MinaAbadir我相信数据文件的名称空间很好。。。但在PagesController中,它是错误的@莫比。。。应该是
use-App\Data
而不是
use-Data
@prateekkathal这就是我说的,他导入了错误的类。
<?php

namespace App\Http\Controllers;

use Request;
use App\Http\Requests;
use Data;
use App\Http\Requests\DataRequest;
use Carbon\Carbon;

class PagesController extends Controller
{
    //Display Index
    public function index()
    {
        return view ('welcome');
    }

    public function create()
    {
        return view ('create');
    }

    //Store Articles from form
    public function store(DataRequest $request)
    {
        Data::create($request->all());
        return redirect('create')->with('message' , 'Form submitted');
    }


}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Http\Requests\DataRequest;
use Carbon\Carbon;

class Data extends Model
{
    protected $fillable = [
        'name',
        'email',
        'phone',
        'company',
        'addcomments',
        'published_at',
    ];

    protected $dates = ['published_at'];

    //Get all published articles by date
    public function scopePublished($query)
    {
        $query->where('published_at' , '<=' , Carbon::now());
    }
    //Get all unpublished or future articles
    public function scopeUnpublished($query)
    {
        $query->where('published_at' , '>=' , Carbon::now());
    }
    // Set form to publish articles with a time and date in the Published_at field
    public function setPublishedAtAttribute($date)
    {
        $this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d' , $date);
    }
}
{!! Form::open(['url' => 'form']) !!}
            <div class="form-group">
                {!! Form::label('name' , 'Name:') !!}
                {!! Form::text('name', null , ['class' => 'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('email' , 'EMail:') !!}
                {!! Form::text('email', null , ['class' => 'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('phone' , 'Phone Number:') !!}
                {!! Form::text('phone', null , ['class' => 'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('company' , 'Company:') !!}
                {!! Form::text('company', null , ['class' => 'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('addcomments' , 'Additional Comments:') !!}
                {!! Form::textarea('addcomments', null , ['class' => 'form-control']) !!}
            </div>
            <div class="form-group">
                {!! Form::submit('Submit Now', ['class' => 'btn btn-primary form-control']) !!}
            </div>
            {!! Form::close() !!}