Open thearabbit opened 9 years ago
there are already solutions in existing issues. I havent used it for l5 yet, but i will start to relase a 3.x version for it
thanks for your reply.
I built a fork and currently updating the Config:get stuff which has been changed in L5
You can use the fixed fork as follows:
Enjoy!
@Chumper Having the best of both worlds would be awesome! I switched form collections to queries and went from 10+secs to under a 1 second for 15,000 records and growing.
L5: compatibility I can understand wanting to get a better and greater version out but with L5 now in the wild maybe having an intern version that with now promises of updating it might relieve lots of "help L5" issues.
@ bart Thanks! Gonna give it a try.
@bart
This worked in 4.2
{!! Datatable::table()
->addColumn('id',trans('kotoba::table.email'), Lang::choice('kotoba::table.role', 2), Lang::choice('kotoba::table.action', 2))
->setUrl(route('api.users'))
->setOptions(array(
'dom' =>"T<'clear'>lfrtip",
'tabletools' => array(
"aSwfPath" => "/assets/Datatables/extensions/TableTools/swf/copy_csv_cls_pdf.swf"
)
))
->render('_partials.datatable')
!!}
This is the error I'm getting
Method Illuminate\View\View::__toString() must not throw an exception
I even tried with not using translations for the addColumn section ....
Any ideas?
Could you publish the stack trace for this error, so that we can find the source for it?
Not much but if it helps.
[2015-02-09 03:23:13] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Method Illuminate\View\View::__toString() must not throw an exception' in /Users/school/Sites/l5/storage/framework/views/940d6d1efb79de99c69a68f0aa469c19:0
Stack trace:
#0 /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(116): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError(Array)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#2 {main}
Nope, unfortunately it does not help. The question is, what has been passed to the view and caused the exception. Does the route name exist?
If I call api/users I get ...
{"aaData":[[1,"admin@admin.com","admin"]],"sEcho":0,"iTotalRecords":1,"iTotalDisplayRecords":1}
L4.2 works.
Could you dump and die the table() method output like so:
dd(Datatable::table()
->addColumn('id',trans('kotoba::table.email'), Lang::choice('kotoba::table.role', 2), Lang::choice('kotoba::table.action', 2))
->setUrl(route('api.users'))
->setOptions(array(
'dom' =>"T<'clear'>lfrtip",
'tabletools' => array(
"aSwfPath" => "/assets/Datatables/extensions/TableTools/swf/copy_csv_cls_pdf.swf"
)
))
->render('_partials.datatable'));
This should return a string but looks like it doesn't which results in the given exception.
Thanks for helping!
Users
View {#259 ▼
#factory: Factory {#135 ▼
#engines: EngineResolver {#132 ▼
#resolvers: array:2 [▼
"php" => Closure {#137 ▼
reflection: """
Closure [ <user> public method Illuminate\View\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/View/ViewServiceProvider.php 56 - 56
}
"""
}
"blade" => Closure {#149 ▼
reflection: """
Closure [ <user> public method Illuminate\View\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/View/ViewServiceProvider.php 79 - 82
- Bound Variables [1] {
Variable #0 [ $app ]
}
}
"""
}
]
#resolved: array:1 [▼
"blade" => CompilerEngine {#254 ▼
#compiler: BladeCompiler {#253 ▶}
#lastCompiled: array:1 [▼
0 => "/Users/school/Sites/l5/app/Modules/Kagi/Providers/../Resources/Views//users/index.blade.php"
]
}
]
}
#finder: FileViewFinder {#140 ▼
#files: Filesystem {#18}
#paths: array:1 [▼
0 => "/Users/school/Sites/l5/resources/views"
]
#views: array:2 [▼
"kagi::users.index" => "/Users/school/Sites/l5/app/Modules/Kagi/Providers/../Resources/Views//users/index.blade.php"
"_partials.datatable" => "/Users/school/Sites/l5/resources/views/_partials/datatable.blade.php"
]
#hints: array:2 [▼
"kagi" => array:1 [▼
0 => "/Users/school/Sites/l5/app/Modules/Kagi/Providers/../Resources/Views/"
]
"flash" => array:2 [▼
0 => "/Users/school/Sites/l5/resources/views/vendor/flash"
1 => "/Users/school/Sites/l5/vendor/caffeinated/flash/src/Caffeinated/Flash/../views"
]
]
#extensions: array:2 [▼
0 => "blade.php"
1 => "php"
]
}
#events: Dispatcher {#5 ▼
#container: Application {#2 ▶}
#listeners: array:3 [▶]
#wildcards: []
#sorted: array:39 [▶]
#firing: []
#queueResolver: Closure {#6 ▶}
}
#container: Application {#2 ▶}
#shared: array:3 [▼
"__env" => Factory {#135}
"app" => Application {#2 ▼
#basePath: "/Users/school/Sites/l5"
#hasBeenBootstrapped: true
#booted: true
#bootingCallbacks: array:4 [▼
0 => Closure {#92 ▼
reflection: """
Closure [ <user> public method Caffeinated\Modules\{closure} ] {
@@ /Users/school/Sites/l5/vendor/caffeinated/modules/src/Caffeinated/Modules/ModulesServiceProvider.php 72 - 74
- Parameters [1] {
Parameter #0 [ <required> $app ]
}
}
"""
}
1 => Closure {#123 ▼
reflection: """
Closure [ <user> public method Caffeinated\Themes\{closure} ] {
@@ /Users/school/Sites/l5/vendor/caffeinated/themes/src/Caffeinated/Themes/ThemesServiceProvider.php 70 - 72
- Parameters [1] {
Parameter #0 [ <required> $app ]
}
}
"""
}
2 => Closure {#143 ▼
reflection: """
Closure [ <user> public method Illuminate\Foundation\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php 547 - 550
- Bound Variables [1] {
Variable #0 [ $instance ]
}
}
"""
}
3 => Closure {#154 ▼
reflection: """
Closure [ <user> public method Illuminate\Foundation\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php 547 - 550
- Bound Variables [1] {
Variable #0 [ $instance ]
}
}
"""
}
]
#bootedCallbacks: array:2 [▼
0 => Closure {#163 ▼
reflection: """
Closure [ <user> public method Illuminate\Foundation\Support\Providers\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php 55 - 58
}
"""
}
1 => Closure {#167 ▼
reflection: """
Closure [ <user> public method Illuminate\Foundation\Support\Providers\{closure} ] {
@@ /Users/school/Sites/l5/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php 55 - 58
}
"""
}
]
#terminatingCallbacks: []
#serviceProviders: array:31 [▶]
#loadedProviders: array:31 [▶]
#deferredServices: array:75 [▶]
#storagePath: null
#environmentFile: ".env"
#resolved: array:41 [▼
"events" => true
"router" => true
"App\Http\Kernel" => true
"Illuminate\Contracts\Http\Kernel" => true
"Illuminate\Foundation\Bootstrap\DetectEnvironment" => true
"Illuminate\Foundation\Bootstrap\LoadConfiguration" => true
"Illuminate\Foundation\Bootstrap\ConfigureLogging" => true
"env" => true
"Illuminate\Foundation\Bootstrap\HandleExceptions" => true
"Illuminate\Foundation\Bootstrap\RegisterFacades" => true
"Illuminate\Foundation\Bootstrap\RegisterProviders" => true
"Illuminate\Foundation\Bootstrap\BootProviders" => true
"files" => true
"modules" => true
"translation.loader" => true
"translator" => true
"view.engine.resolver" => true
"view.finder" => true
"view" => true
"themes" => true
"db.factory" => true
"db" => true
"Illuminate\Bus\Dispatcher" => true
"url" => true
"Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode" => true
"encrypter" => true
"Illuminate\Cookie\Middleware\EncryptCookies" => true
"cookie" => true
"Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse" => true
"session" => true
"Illuminate\Session\Middleware\StartSession" => true
"Illuminate\View\Middleware\ShareErrorsFromSession" => true
"App\Http\Middleware\VerifyCsrfToken" => true
"illuminate.route.dispatcher" => true
"App\User" => true
"App\Modules\Kagi\Http\Controllers\UsersController" => true
"blade.compiler" => true
"auth" => true
"hash" => true
"session.store" => true
"datatable" => true
]
#bindings: array:58 [▶]
#instances: array:35 [▶]
#aliases: array:60 [▶]
#extenders: []
#tags: []
#buildStack: []
+contextual: []
#reboundCallbacks: array:2 [▼
"request" => array:3 [▶]
"routes" => array:1 [▶]
]
#globalResolvingCallbacks: []
#globalAfterResolvingCallbacks: []
#resolvingCallbacks: array:1 [▼
"Illuminate\Foundation\Http\FormRequest" => array:1 [▶]
]
#afterResolvingCallbacks: array:1 [▼
"Illuminate\Contracts\Validation\ValidatesWhenResolved" => array:1 [▶]
]
}
"errors" => ViewErrorBag {#190 ▼
#bags: []
}
]
#aliases: []
#names: []
#extensions: array:2 [▼
"blade.php" => "blade"
"php" => "php"
]
#composers: []
#sections: array:4 [▼
"title" => """
@parent
␉:
␉kotoba::account.users
"""
"styles" => """
␉<link rel="stylesheet" href="http://l5.local/assets/vendors/Datatables-Bootstrap3/BS3/assets/css/datatables.css">
"""
"scripts" => """
␉<script src="http://l5.local/assets/js/restfulizer.js"></script>
␉<script src="http://l5.local/assets/vendors/DataTables/media/js/jquery.dataTables.min.js"></script>
"""
"inline-scripts" => """
var text_confirm_message = 'Delete this User?';
$(document).ready(function() {
␉$('#DataTable').dataTable({
␉␉stateSave: true
␉});
␉$('#DataTable').each(function(){
␉␉var datatable = $(this);
␉␉var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
␉␉search_input.attr('placeholder', 'Search');
␉␉search_input.addClass('form-control input-sm');
␉␉var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
␉␉length_sel.addClass('form-control input-sm');
␉});
});
"""
]
#sectionStack: array:1 [▼
0 => "content"
]
#renderCount: 1
}
#engine: CompilerEngine {#254 ▶}
#view: "_partials.datatable"
#data: array:8 [▼
"options" => array:6 [▼
"sPaginationType" => "full_numbers"
"bProcessing" => false
"sAjaxSource" => "http://l5.local/api/users"
"bServerSide" => true
"dom" => "T<'clear'>lfrtip"
"tabletools" => array:1 [▼
"aSwfPath" => "/assets/Datatables/extensions/TableTools/swf/copy_csv_cls_pdf.swf"
]
]
"callbacks" => []
"values" => []
"data" => []
"columns" => array:4 [▼
1 => "id"
2 => "Email"
3 => "Roles"
4 => "Actions"
]
"noScript" => false
"id" => "k64o6wVA"
"class" => "table table-bordered"
]
#path: "/Users/school/Sites/l5/resources/views/_partials/datatable.blade.php"
}
I would suggest it is an error in your view _partials.datatable. But I'm not a hundred percent sure. Hope you can find and fix it. Does the error occur, when you don't use your own template like this:
Datatable::table()
->addColumn('id',trans('kotoba::table.email'), Lang::choice('kotoba::table.role', 2), Lang::choice('kotoba::table.action', 2))
->setUrl(route('api.users'))
->setOptions(array(
'dom' =>"T<'clear'>lfrtip",
'tabletools' => array(
"aSwfPath" => "/assets/Datatables/extensions/TableTools/swf/copy_csv_cls_pdf.swf"
)
))
->render();
For those who are looking for step by step guidance in using Chumper Datatable with Larave5 , http://jayeshmagare.blogspot.com/2015/02/using-chumper-datatable-in-laravel-5.html
Followed the step by step blog posts provided ... unfortunately they don't appear to work very well. Will need to wait for a proper package to be developed for L5.
Maybe you could use this meanwhile: https://github.com/yajra/laravel-datatables-oracle
The yajra package sort of works. The issues I'm coming up with the final initialization part -- essentially no sorting. Plus I'm skeptic that is as fast as chumper can be. I'm using it until chumper comes online or until I can get one of the chumper L5 fixes working.
@bart Installed fine (using your method above) and the /api/supply route work but getting a "No hint path defined for [datatable]" error. I assume I did something wrong, but searches haven't turned anything up.
InvalidArgumentException in FileViewFinder.php line 112:
No hint path defined for [datatable].
in FileViewFinder.php line 112
at FileViewFinder->getNamespaceSegments('datatable::template') in FileViewFinder.php line 88
at FileViewFinder->findNamedPathView('datatable::template') in FileViewFinder.php line 74
at FileViewFinder->find('datatable::template') in Factory.php line 145
at Factory->make('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'AlIyu91r', 'class' => 'table table-bordered')) in Facade.php line 213
at Facade::__callStatic('make', array('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'AlIyu91r', 'class' => 'table table-bordered'))) in Table.php line 309
at View::make('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'AlIyu91r', 'class' => 'table table-bordered')) in Table.php line 309
at Table->render() in 12d5e1546aef0d0ee0fbffc17b8da471 line 74
Hint path of death :sob:
@ proto What's on line 74 of that cache file?
Oops, just noticed there were 2 errors here is #1/2
InvalidArgumentException in FileViewFinder.php line 112:
No hint path defined for [datatable].
in FileViewFinder.php line 112
at FileViewFinder->getNamespaceSegments('datatable::template') in FileViewFinder.php line 88
at FileViewFinder->findNamedPathView('datatable::template') in FileViewFinder.php line 74
at FileViewFinder->find('datatable::template') in Factory.php line 145
at Factory->make('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'OLDey4YY', 'class' => 'table table-bordered')) in Facade.php line 213
at Facade::__callStatic('make', array('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'OLDey4YY', 'class' => 'table table-bordered'))) in Table.php line 309
at View::make('datatable::template', array('options' => array('sPaginationType' => 'full_numbers', 'bProcessing' => false, 'sAjaxSource' => 'http://nlccdb.new/api/supply', 'bServerSide' => true), 'callbacks' => array(), 'values' => array(), 'data' => array(), 'columns' => array(), 'noScript' => false, 'id' => 'OLDey4YY', 'class' => 'table table-bordered')) in Table.php line 309
at Table->render() in 12d5e1546aef0d0ee0fbffc17b8da471 line 74
at include('/vagrant/lv/nlccdb.new/storage/framework/views/12d5e1546aef0d0ee0fbffc17b8da471') in PhpEngine.php line 39
at PhpEngine->evaluatePath('/vagrant/lv/nlccdb.new/storage/framework/views/12d5e1546aef0d0ee0fbffc17b8da471', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'user' => object(User), 'person' => object(Person))) in CompilerEngine.php line 57
at CompilerEngine->get('/vagrant/lv/nlccdb.new/resources/views/supply/store.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'user' => object(User), 'person' => object(Person))) in View.php line 136
at View->getContents() in View.php line 104
at View->renderContents() in View.php line 78
at View->render() in Response.php line 44
It mentions datatable::template
a couple times In Chumper\Datatable\Table.php the return View::make();
variable $this->table_view
returns that value.. Does this help?
EDIT: Alright, I have some pretty awesome Google-ing skills (found here) so adding View::addNamespace('datatable', __DIR__.'/../../views');
before the View::make();
is called in Table.php
fixes the issue, however only the table HTML layout is produce... No content form the ajax call.
So for somereason the namespace isn't being registered in laravel properly.
Holy. Okay so after troubleshooting for about an hour I finally got everything working. Took me a while to figure out the namespace issue, then I was accidentally using datatables 1.10, and finally had to figure out how to properly use Datatable::table() + Datatable::collection().
That was super fun.
@bart @illuminate3 So my vagrant box farted yesterday and I had to re vagrant up, composer update, pa migrate, pa seed, etc
and now Datatable is giving me some new errors.
Exception in Table.php line 159:
Invalid number of options provided for the method "setOptions"
I dd($this->config);
in Table.php __contruct(); and it came back null. The config isn't being pulled properly. I ran pa vendor:publish
and verified the config generated properly.
Any ideas?
EDIT: Here is the more of the exception if it helps, but I've narrowed it down to the Config::get()
not pulling anything.
Exception in Table.php line 159:
Invalid number of options provided for the method "setOptions"
in Table.php line 159
at Table->setOptions(null) in Table.php line 87
at Table->__construct() in Datatable.php line 39
at Datatable->table() in Facade.php line 207
at Facade::__callStatic('table', array()) in 12d5e1546aef0d0ee0fbffc17b8da471 line 36
at DatatableFacade::table() in 12d5e1546aef0d0ee0fbffc17b8da471 line 36
at include('/vagrant/lv/nlccdb.new/storage/framework/views/12d5e1546aef0d0ee0fbffc17b8da471') in PhpEngine.php line 39
EDIT2: Alright so I fixed it by adding "packages." to $this->config = Config::get('packages.chumper_datatable.table');
I always ask too early. thanks for letting me bounce it off the internet.
how to install for L5?