gpt4 book ai didi

datatable - "Class datatables does not exist"使用 "yajra"laravel 数据表时出错

转载 作者:行者123 更新时间:2023-12-04 22:11:05 31 4
gpt4 key购买 nike

我想通过 显示我的帖子表行列表datatables 带有 Laravel 5.1 版的 jquery 插件通过 yajra-laravel-datatables .

为此,我执行了此 Quick Start Giude 中描述的所有说明在我的项目中。

这是我的路线,仅用于获取 dataTable 所需的所有数据:

Route::get('postsData', 'postController@testData');

这是完整的 postController php 文件:
namespace App\Http\Controllers;

use App\Http\Requests;
use App\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use yajra\Datatables\Datatables;

class postController extends Controller
{

public function index ()
{
$allPosts = Post::all();
return \View::make('admin.pages.posts')->with('posts', $allPosts);
}


public function create ()
{
return \View::make('admin.pages.post_create');
}


public function store (Request $request)
{
$data = Input::all();

$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);

$validator = \Validator::make($data, $rules);

if ($validator->fails()) {
return \Redirect::to('/admin/posts/create')
->withErrors($validator)
->withInput();
} else {

$post = new Post();
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();

return \Redirect::to('/admin/posts');
}
}


public function show ($id)
{
$post = Post::find($id);

return \View::make('admin.pages.show_post')->with('post', $post);
}


public function edit ($id)
{
$post = Post::find($id);
return \View::make('admin.pages.edit_post')->with('post', $post);
}


public function update (Request $request, $id)
{
$data = Input::all();

$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);

$validator = \Validator::make($data, $rules);

if ($validator->fails()) {
return \Redirect::to('post/create')
->withErrors($validator)
->withInput();
} else {

$post = Post::find($id);
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();

return \Redirect::to('admin/posts');
}
}


public function destroy ($id)
{
$post = Post::find($id);
$post->delete();

return Redirect::to('admin/posts');
}


public function postsAll(){
return View::make('admin.pages.postsAll');
}

public function testData(){
return Datatables::of(Post::select('*'))->make(true);
}
}

我也加 服务提供商和立面 config/app.php :
return [
'debug' => env('APP_DEBUG', false),
'url' => 'http://localhost',
'timezone' => 'UTC',
'locale' => 'en',
'fallback_locale' => 'en',
'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC',
'log' => 'single',


'providers' => [

/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
yajra\Datatables\DatatablesServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

],



'aliases' => [

'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Datatables' => yajra\Datatables\Datatables::class,

],

];

这是 的结构亚杰拉 供应商 Composer 文件夹:

enter image description here

但是当我打开 帖子数据 浏览器中的路径此错误显示:
ReflectionException in Container.php line 737:
Class datatables does not exist

什么是问题?

最佳答案

经过数小时的谷歌搜索后,我找到了解决方案并尝试了不同的方法:

1.首先将您的项目重命名为新名称。
2.使用composer update3.运行php artisan config:cache4.然后运行php artisan cache:clear
并再次尝试您的代码。

关于datatable - "Class datatables does not exist"使用 "yajra"laravel 数据表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33122553/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com