Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Query Builder instead of Eloquent model? #3

Closed
sunnyjayjay opened this issue Oct 8, 2015 · 8 comments
Closed

Using Query Builder instead of Eloquent model? #3

sunnyjayjay opened this issue Oct 8, 2015 · 8 comments
Assignees

Comments

@sunnyjayjay
Copy link

Is it possible to use a Query Builder instead of Eloquent model with this? I have tried and it fails. Basically I want to join tables in a dynamic query and get the results to display. But even something as simple as

$rows = DB::table('users')->get(); 
$table = Table::create($rows); 
return view('reports.generic', ['table' => $table]);

falls over.

@gbrock gbrock self-assigned this Oct 9, 2015
@gbrock
Copy link
Owner

gbrock commented Oct 9, 2015

This capability will be included in the next version. Thanks for bringing it to my attention.

@sunnyjayjay
Copy link
Author

Thanks. Do you have any idea of the timeframe for this?

@gbrock
Copy link
Owner

gbrock commented Oct 12, 2015

I went ahead and pushed this upstream from the new version so you can use it now. It isn't sortable, but the 0.3.1 release allows for basic rendering.

@sunnyjayjay
Copy link
Author

Thanks. I downloaded your update and tried the example exactly as I posted at the start of this thread and it falls over with:

FatalErrorException in Table.php line 114:
Call to a member function first() on array

My blade file has no other code, only

{!! $table->render() !!}

@gbrock
Copy link
Owner

gbrock commented Oct 12, 2015

It looks like you have an older version installed, but that wouldn't really have mattered since the version I directed you to was fully broken due to a typo. I just pushed another update, so please make sure your composer.json is requesting dev-master or 0.3.2.

@sunnyjayjay
Copy link
Author

I have checked and I am using your latest version, I have compared Table.php line by line between my local copy and the version here on Github. But I get the error I posted above, that first() cannot be used on an array at line 114 in Table.php.

@gbrock
Copy link
Owner

gbrock commented Oct 14, 2015

OK, I've been digging deeper. It looks like I was doing simple testing via a $query->paginate(), while the error occurs specifically with the standard $query->get(). I just pushed 0.3.3, please see if this works for your scenario.

@sunnyjayjay
Copy link
Author

Thanks - that works a treat!

@gbrock gbrock closed this as completed Oct 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants