Giter Club home page Giter Club logo

Comments (9)

rcrowe avatar rcrowe commented on August 22, 2024

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
User => belongsTo => Group
// Controller
public function getIndex()
{
$user = User::first();
return View::make('view')->with('user', $user);
}
In a PHP view I wrote :

group->name; ?>

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.

rcrowe avatar rcrowe commented on August 22, 2024

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.

billmn avatar billmn commented on August 22, 2024

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.

rcrowe avatar rcrowe commented on August 22, 2024

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.

rcrowe avatar rcrowe commented on August 22, 2024

You've got a clash of meido/form.

anahkiasen/former & twigbirdge require different versions. Dam.

from twigbridge.

rcrowe avatar rcrowe commented on August 22, 2024

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.

billmn avatar billmn commented on August 22, 2024

Yeah ... you're right.

Thank you for the support

from twigbridge.

rcrowe avatar rcrowe commented on August 22, 2024

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.

billmn avatar billmn commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.