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

LogicException in Model.php line 2702: Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation #239

Closed
msonowal opened this issue Jun 29, 2016 · 6 comments

Comments

@msonowal
Copy link

msonowal commented Jun 29, 2016

LogicException in Model.php line 2702:
Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

$model = Menu::findOrFail($id);
        $form = $formBuilder->create('App\Forms\MenuForm', [
            'method' => 'PUT',
            'model' => $model,
            'url' => route('admin.menus.update', $id)
        ])->add('Update', 'submit', [
                'attr' => ['class' => 'btn btn-lg btn-success col-xs-12']
        ]);

but If I remove the last line it works fine i.e.

$model = Menu::findOrFail($id);
        $form = $formBuilder->create('App\Forms\MenuForm', [
            'method' => 'PUT',
            'model' => $model,
            'url' => route('admin.menus.update', $id)
        ])

It is happening with latest updated version, previosuly it was working fine with my same project running version 1.6 but current version is 1.7

@kristijanhusak
Copy link
Owner

Can you just try using different name for submit btn, something like this:

$model = Menu::findOrFail($id);
        $form = $formBuilder->create('App\Forms\MenuForm', [
            'method' => 'PUT',
            'model' => $model,
            'url' => route('admin.menus.update', $id)
        ])->add('Submit', 'submit', [
                'attr' => ['class' => 'btn btn-lg btn-success col-xs-12'],
                'label' => 'Update'
        ]);

@kristijanhusak
Copy link
Owner

@msonowal please let me know if that worked out for you.

@msonowal
Copy link
Author

msonowal commented Jun 30, 2016

@kristijanhusak first of all thanks. It's working. but I really want to know why it was workin before and now not working I use to add buttons like that, but from now I have to use only Submit if I want to add button right?

@kristijanhusak
Copy link
Owner

@msonowal it is related to this issue #232

Basically none of the eloquent method names are allowed. since Eloquent class has update() method, it crashes with this error. Like it is mentioned in the issue #232, i added the save to reserved words, but i'll do it a bit more dynamic.

@msonowal
Copy link
Author

msonowal commented Jul 2, 2016

thank you for your reply
And one more question is there form helper for generating horizontal forms I am unable to find in the docs like below example

 <form class="form-horizontal">
<div class="form-group">
 <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
 <div class="col-sm-10">
   <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
 </div>
</div>
 <div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
 </div>

@kristijanhusak
Copy link
Owner

@msonowal there is no templates for that, there's an open issue #175 , but i didn't have time to add that to the package. If you want create it and make a PR.

@msonowal msonowal closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants