Comments (9)
Are you using v0.1.5 should have been fixed with the latest version.
On 17 Jan 2013, at 11:58, Davide Bellini [email protected] wrote:
I have 2 models ( User, Group ) with relations :
Group => hasMany => User
group->name; ?>
User => belongsTo => Group
// Controller
public function getIndex()
{
$user = User::first();
return View::make('view')->with('user', $user);
}
In a PHP view I wrote :And it works fine but if I use a Twig view with :
{{ user.group.name }}
I get an error :Twig_Error_Runtime:
An exception has been thrown during the rendering of a template ("Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Database\Query\Builder' does not have a method 'name' in /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php line 443") in "form.twig" at line 14.
If I get a property of the User class like {{ user.username }} it works ... seems that there's a problem with relations—
Reply to this email directly or view it on GitHub.
from twigbridge.
You should be using the latest version then.
I just checked this, when using the relation in reverse (belongsTo) like you seem to be doing, everything works fine.
I can only get the error when going the other way with your code. So:
$group = Group::first();
{{ group.users.id }}
My setup:
Users -> hasMany -> Pages
Pages -> belongsTo -> Users
Then this works:
$page = Page::first();
echo $page->user->username
After checking this just now it works fine for me. I'll do my best to try and recreate your problem and get back to you.
from twigbridge.
With 1.0.5 ("rcrowe/twigbridge": "v0.1.5")
I've get on composer update :
Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - anahkiasen/former dev-composer requires meido/form dev-master -> satisfiable by meido/form dev-master. - anahkiasen/former dev-composer requires meido/form dev-master -> satisfiable by meido/form dev-master. - Can only install one of: meido/form v1.1.0, meido/form dev-master. - rcrowe/twigbridge v0.1.5 requires meido/form 1.1.*@stable -> satisfiable by meido/form v1.1.0. - Installation request for rcrowe/twigbridge v0.1.5 -> satisfiable by rcrowe/twigbridge v0.1.5. - Installation request for anahkiasen/former dev-composer -> satisfiable by anahkiasen/former dev-composer.
from twigbridge.
This is my composer file for Laravel:
{
"require": {
"laravel/framework": "4.0.*",
"rcrowe/twigbridge": "0.1.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/tests/TestCase.php"
]
},
"minimum-stability": "dev"
}
Is yours different to this, in terms of laravel/framework, minimum-stability, etc?
from twigbridge.
You've got a clash of meido/form.
anahkiasen/former & twigbirdge require different versions. Dam.
from twigbridge.
Just putting:
"require": {
"laravel/framework": "4.0.*",
"anahkiasen/former": "dev-composer",
"rcrowe/twigbridge": "0.1.*"
}
Will actually install version 0.1.3 of TwigBridge which doesn't support Eloquent
from twigbridge.
Yeah ... you're right.
Thank you for the support
from twigbridge.
What I probably should do is remove the require for Meidos HTML & Form libraries as they are used by an extension that shouldn't be forced upon people.
Then remove the extension loading by default and put a "suggest" in the composer file.
It won't be this weekend I sort it out, but Monday or Tuesday I will get on it. Should fix this issue for you.
from twigbridge.
I've solved now with a form of Former and fixing Meido version references ... in any case, thank you very much!
from twigbridge.
Related Issues (20)
- Enabled Laravel 8 HOT 2
- Include markdown files
- Migrate to Github actions
- store templates in database HOT 1
- [Question] Laravel8 + TwigBridge + GraphQL Twig extension -- example or available package?
- trans node is missing?
- Full example for adding an existing Twig Extension to Laravel8 +TwigBridge?
- How to use twigphp/cache-extra? HOT 2
- Not working in Lumen HOT 1
- View::composer not working v.0.14.0 HOT 3
- Deprecated Messages [php 8.2+]
- Bridge Version says it's v0.10.0 on v0.14.1
- os
- How would I go about adding an extension that needs configuration? HOT 1
- Relative include paths don't work when using namespaces HOT 4
- Laravel Collective HTML package is abandoned HOT 5
- Twig cache file has path instead of name in laravel view cache for getTemplateName() HOT 3
- TwigBridge 0.14.* not compatible with Twig 3.9.0 HOT 5
- $path being null causes deprecation warnings in logs when using Telescope
- Vite in Twig (rcrowe/TwigBridge) for Laravel 11 [SOLUTION]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twigbridge.