Coder Social home page Coder Social logo

Comments (14)

ankurk91 avatar ankurk91 commented on July 19, 2024 1

Some insights -

// routes/web.php
Route::resource(
        'users', 'UserController', ['only' => [
            'index', 'store', 'edit', 'update'
        ]]
    );

Ziggy example

route('users.edit',{user:1}).url()

Result -

"http://app.local/users/1/edit"

It does not look for id but user property because the route requires {user}.

$ php artisan route:list | grep users.edit

|        | GET|HEAD  | users/{user}/edit                   | users.edit              | App\Http\Controllers\UserController@edit                               | web,auth,role:admin,can:manage-users,user                 |

Notice the {user} in url

from ziggy.

DanielCoulbourne avatar DanielCoulbourne commented on July 19, 2024 1

Yeah that test is passing...
@lamberttraccard if you can give me a combination of a route definition and a Ziggy usage that makes this break, please re-open.

I'd love a failing test

from ziggy.

the94air avatar the94air commented on July 19, 2024 1

It is not merged yet as Daniel said

It may have gotten lost in the big rewrite. I'll go back and look to see if it's there.

@DanielCoulbourne can you look at @avrahamappel test

from ziggy.

fridzema avatar fridzema commented on July 19, 2024 1

I had this error a few times now.
Make sure that the value you are passing to object is defined/not empty!

from ziggy.

DanielCoulbourne avatar DanielCoulbourne commented on July 19, 2024

Thanks I’ll look into this today.

from ziggy.

DanielCoulbourne avatar DanielCoulbourne commented on July 19, 2024

@lamberttraccard can you show me the code that caused this error?

from ziggy.

lamberttraccard avatar lamberttraccard commented on July 19, 2024

@DanielCoulbourne
capture d ecran 2017-11-16 a 08 38 43

from ziggy.

lamberttraccard avatar lamberttraccard commented on July 19, 2024

Thanks @ankurk91, yes it's seems that Ziggy doesn't work with route model binding.

from ziggy.

DanielCoulbourne avatar DanielCoulbourne commented on July 19, 2024

I know we did support looking up by generic ID at one point. I believe @jesseleite wrote that.

It may have gotten lost in the big rewrite. I'll go back and look to see if it's there.

from ziggy.

jesseleite avatar jesseleite commented on July 19, 2024

Yessir 👌 https://github.com/tightenco/ziggy/blob/master/tests/js/test.route.js#L101-L113

from ziggy.

avrahamappel avatar avrahamappel commented on July 19, 2024

@DanielCoulbourne
I'm having this issue as well.

route('contracts.revise', {id:1}).url()

I get

Uncaught Error: Ziggy Error: 'contract' key is required for route 'contracts.revise'

Route definition:

Route::post('contracts/{contract}/revise', 'ContractController@revise')->name('contracts.revise');

I don't have anything filtered right now.

from ziggy.

the94air avatar the94air commented on July 19, 2024

Try this @avrahamappel

route('contracts.revise', {contract:1}).url()

from ziggy.

avrahamappel avatar avrahamappel commented on July 19, 2024

I understand, but that was my test case. In reality I'm passing a JavaScript representation of an Eloquent Model in there, and according to what I understood from the above discussion, Ziggy should be able to find the id field in the object.

from ziggy.

DanielCoulbourne avatar DanielCoulbourne commented on July 19, 2024

Will do! May be a day or two unfortunately but thanks for the heads up.

from ziggy.

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.