Laravel 4 Laravel缺少参数2

Laravel 4 Laravel缺少参数2,laravel-4,Laravel 4,第二个论点缺失 Illumb\Database\Eloquent\Model::setAttribute(),在中调用 /vagrant/vendor/laravel/framework/src/illumb/Database/elount/Model.php 第2335行,并定义 以上是我在上传CSV文件时遇到的问题 控制器: public function postUpload () { if ( Input::hasFile('file') ) { DB:

第二个论点缺失 Illumb\Database\Eloquent\Model::setAttribute(),在中调用 /vagrant/vendor/laravel/framework/src/illumb/Database/elount/Model.php 第2335行,并定义

以上是我在上传CSV文件时遇到的问题

控制器:

 public function postUpload ()
{
    if ( Input::hasFile('file') )
    {
        DB::transaction(function()
        {
            // Clear out what we have written
            DB::table('wc_program')->delete();

            $csv = new CsvFile(Input::file('file')->getRealPath());

            // Get the csv headers and move to the next line (the start of actual data)
            $columns = $csv->getHeader();
            $csv->next();

            // Loop through the rows creating / saving a record for each
            while( $csv->valid() )
            {
                $row = $csv->current();
                $pc = new Programmes();

                for( $i=0; $i<count($columns); $i++ )
                {
                    $pc->$columns[$i] = $row[$i];
                }

                $pc->save();
                $csv->next();
            }
        });

    return Redirect::to('admin/programmes')->with('flash_success', 'Upload completed &amp; new data inserted.');
    }
路线设置如下:

Route::get('admin/programmes/excelUpload','ProgrammesController@excelUpload');
Route::post('admin/programmes/doUpload', ['as' => 'admin.programmes.doUpload', 'uses' => 'ProgrammesController@postUpload']);

代码段
illumb\Database\elount\Model::setAttribute()
需要两个参数,即key及其值。在指定给列时,您的值似乎丢失了

我建议您在附近调试代码

$pc->$columns[$i] = $row[$i];
如果您发现有帮助,请更新您的问题:)

$pc->$columns[$i] = $row[$i];