Coder Social home page Coder Social logo

Comments (6)

peterfox avatar peterfox commented on July 19, 2024 4

@sebastiandedeyne sure I'll try and fit in some time to take a look

from inertia-laravel.

sebastiandedeyne avatar sebastiandedeyne commented on July 19, 2024

This looks like a bug to me. @peterfox any chance you could do a follow up PR that fixes this? 😇

from inertia-laravel.

peterfox avatar peterfox commented on July 19, 2024

It's really weird this behaviour seems to happen with Macros but doesn't happen with the router view method that does literally the same thing.

The following code for the controller I believe fixes the issue. I have a feeling this might be related to the Laravel version as well, it looks like the controller for Route::view has changed in L6, it might just be a cosmetic reason for changing though. @marvinrabe are you using Laravel 6?

<?php

namespace Inertia;

use Illuminate\Http\Request;

class Controller
{
    public function __invoke(Request $request)
    {
        return Inertia::render(
            $request->route()->defaults['component'],
            $request->route()->defaults['props']
        );
    }
}

from inertia-laravel.

marvinrabe avatar marvinrabe commented on July 19, 2024

@peterfox No, I am still on Laravel 5.8. Haven't tested it with Laravel 6 yet.

from inertia-laravel.

marvinrabe avatar marvinrabe commented on July 19, 2024

@peterfox It seems like injecting parameters in controller methods is always done by order. See the documentation:

Route parameters are injected into route callbacks / controllers based on their order - the names of the callback / controller arguments do not matter.

Up until now I did not know this. I find this quite unintuitive. I opened a feature proposal for changing this behaviour.

from inertia-laravel.

Lelectrolux avatar Lelectrolux commented on July 19, 2024

@marvinrabe

I find this quite unintuitive

It allows you to do this :

// matches 'GET /1/my-article-slug'
Route::get('/{writer}/{article_slug}', function(Writer $writer, Article $article) {
    // Here I can use $article instead of $article_slug/$articleSlug
});

from inertia-laravel.

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.