我正在尝试在我的laravel项目中的数据表中显示一些数据,但是我遇到一个错误,表示我的数据格式不正确我知道数据格式正确,因为我有其他数据表使用相同的数据这是我的控制器:
<?php
namespace App\Http\Controllers;
use Datatable;
use View;
use App\Models\EC2Instance;
use App\Models\ChangedProperties;
use Illuminate\Support\Facades\Input;
use App\Models\ChangelogItem;
class ChangedPropertiesController extends Controller {
protected $layout = 'changed_properties';
public function details($changelog_item_id)
{
$changed_property = new ChangedProperties;
$changed_properties = $changed_property->where('changelog_item_id', $changelog_item_id)->get();
$table = Datatable::table()
->addColumn(
'Changed Property', 'Change Type', 'Changelog Item ID', 'Previous Value', 'Updated Value'
)
->setUrl('/changed_properties/'. $changed_properties)
->noScript();
return View::make('changed_properties')
->with('property',$changed_properties)
->with('table', $table);
}
public function instance_details($changelog_item_id)
{
$query = ChangedProperties::select(array('resource_id',
'resource_type',
'changed_property',
'change_type',
'previous_value',
'updated_value',
'changelog_item_id'
))
->get();
return Datatable::collection($query)
->showColumns(
'changed_property', 'change_type','changelog_item_id', 'previous_value', 'updated_value')
->searchColumns( 'changed_property', 'change_type', 'previous_value', 'updated_value')
->orderColumns( 'changed_property', 'change_type', 'previous_value', 'updated_value'
)
->make();
}
}
和路线:
/Homepage Route
Route::get('/', 'CRUDController@users');
// Route which populates datatable in homepage
Route::get('search', array('as' => 'instance.search', 'uses' => 'CRUDController@instances'));
//route which renders instance details
Route::get('/instance_details/{instance_id}','DetailsController@details');
//route which links to individual instance details
Route::get('/ec2_instance/{resource_type}/{resource_id}',array('as'=>'InstanceId', 'uses'=>'DetailsController@instance_details'));
//route which renders changed properties for changelog item
Route::get('/changed_properties/{changelog_item_id}/','ChangedPropertiesController@details');
//route which links to individual instance details
Route::get('/changed_properties/{changlog_item_id}/',array('as'=>'ChangelogItemId', 'uses'=>'ChangedPropertiesController@instance_details'));
Route::resource('sns', 'SNSController');