Laravel 5 未找到类“App\Http\Controllers\DbTableDataProvider”
我正在将一个名为view components/grids的新组件集成到Laravel 5.4中, 我安装的槽式作曲家 composer需要视图组件/网格 编写器需要视图组件/雄辩的数据处理 之后,我想我需要在app.conf中添加提供者和别名,因为文档中没有提到它,但我应该添加哪些名称 找不到类“App\Http\Controllers\DbTableDataProvider” 文档中提到它与Laravel兼容, 是否有人将此组件网格集成到laravel中,我如何使其工作? 提前谢谢Laravel 5 未找到类“App\Http\Controllers\DbTableDataProvider”,laravel-5,components,Laravel 5,Components,我正在将一个名为view components/grids的新组件集成到Laravel 5.4中, 我安装的槽式作曲家 composer需要视图组件/网格 编写器需要视图组件/雄辩的数据处理 之后,我想我需要在app.conf中添加提供者和别名,因为文档中没有提到它,但我应该添加哪些名称 找不到类“App\Http\Controllers\DbTableDataProvider” 文档中提到它与Laravel兼容, 是否有人将此组件网格集成到laravel中,我如何使其工作? 提前谢谢 use
use Illuminate\Http\Request;
use App\Red;
use ViewComponents\Eloquent\EloquentDataProvider;
class testController extends Controller
{
public function index(){
$provider = new EloquentDataProvider(Red::class);
$input = new InputSource($_GET);
// create grid
$grid = new Grid(
$provider,
// all components are optional, you can specify only columns
[
new TableCaption('My Grid'),
new Column('id'),
new Column('nombre'),
new Column('created_at'),
new DetailsRow(new SymfonyVarDump()), // when clicking on data rows, details will be shown
new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
new PageSizeSelectControl($input->option('page_size', 5), [2, 5, 10]), // allows to select page size
new ColumnSortingControl('id', $input->option('sort')),
new ColumnSortingControl('nombre', $input->option('sort')),
new FilterControl('nombre', FilterOperation::OPERATOR_LIKE, $input->option('nombre')),
new CsvExport($input->option('csv')), // yep, that's so simple, you have CSV export now
new PageTotalsRow([
'id' => PageTotalsRow::OPERATION_IGNORE,
// 'age' => PageTotalsRow::OPERATION_AVG
])
]
);
// now you can render it:
echo $grid->render();
// or even this way:
echo $grid;
return view('test.tabla', compact('grid')); <--- is this right?
}
您还必须安装更多信息:
然后根据中的指令设置$provider变量,而不是$provider=new DbTableDataProvider$pdoConnection,'my_table'
例如:
使用MyApp\UserModel;
使用ViewComponents\Eloquent\EloquentDataProvider;
$provider=新的EloquentDataProviderUserModel::class;
并添加这些引用
使用ViewComponents\ViewComponents\Input\InputSource;
使用ViewComponents\Grids\Grid;
使用ViewComponents\Grids\Component\TableCaption;
使用ViewComponents\Grids\Component\Column;
使用ViewComponents\Grids\Component\DetailsRow;
使用ViewComponents\Grids\Component\ColumnSortingControl;
使用ViewComponents\Grids\Component\CsvExport;
使用ViewComponents\Grids\Component\PageTotalsRow;
使用ViewComponents\ViewComponents\Component\Control\PaginationControl;
使用ViewComponents\ViewComponents\Component\Control\PageSizeSelectControl;
使用ViewComponents\ViewComponents\Component\Control\FilterControl;
您可以在这两个存储库中找到对类的所有引用
您好Ravisha,您的帖子很有帮助,我按照您提到的那样做了,现在我没有找到类“App\Http\Controllers\InputSource”,我将更新上面的代码以显示所做的更改,并引用use ViewComponents\ViewComponents\Input\InputSource,或者因为laravel有请求类,所以您可以使用$Request->Input'page',1';而不是$input->option'page',1在最后一次工作时,我不得不添加这个更必要的行,使用ViewComponents\ViewComponents\Component\Control\FilterControl;使用ViewComponents\ViewComponents\Component\Debug\SymfonyVarDump;使用ViewComponents\ViewComponents\Data\Operation\FilterOperation;使用ViewComponents\ViewComponents\Customization\CssFrameworks\BootstrapStyling;谢谢,这个网格允许编辑吗?我没有看到记录的编辑按钮实际上我不熟悉这个包,但是根据文档,你不能编辑网格。