Git Product home page Git Product logo

Comments (7)

kdion4891 avatar kdion4891 commented on June 29, 2024

What version of PHP are you running? Also, is this Laravel 7?

I noticed similar problems with Laravel 7 and a PHP version below 7.3. After I set my PHP version to 7.3 these issues went away.

from laravel-livewire-tables.

on3ss avatar on3ss commented on June 29, 2024

I'm using laravel 6.18 and php 7.2

from laravel-livewire-tables.

Jean-Da-Rocha avatar Jean-Da-Rocha commented on June 29, 2024

@kdion4891 I have the same problem.

public $projectId;

public function mount(Project $project)
{
    $this->setTableProperties();
    $this->projectId = $project->id;
}

I'm running Laravel 7, php 7.3 and livewire 1.x

from laravel-livewire-tables.

oliverbj avatar oliverbj commented on June 29, 2024

Same issue for me. It's because in the "original" mount method, there is no argument being passed to it.

How can we solve this?

from laravel-livewire-tables.

oliverbj avatar oliverbj commented on June 29, 2024

So what I did to "solve" this, was to extend the TableComponent that all new DataTable classes have. I have created my own "CustomTableComponent" (call it what you want):

This custom component then extends the TableComponent, but in here I can successfully override the mount() method, to accept (in my case) an $id.

class CustomTableComponent extends TableComponent
{

    public function mount($id = null)
    {
        $this->setTableProperties();
    }

}

In my DataTable class, I simply then extend my CustomTableComponent:

class UserTable extends CustomTableComponent
{
    public $user_id;
    public function mount($id = null)
    {
        $this->user_id = $id;
        parent::mount($this->user_id);
    }
}

from laravel-livewire-tables.

kdion4891 avatar kdion4891 commented on June 29, 2024

if someone comes up with a decent solution please submit a PR

from laravel-livewire-tables.

rumeau avatar rumeau commented on June 29, 2024

Hello i've came on this same issue recently.

I'm not sure, but doesn't seems correct to hijack the mount method as is the single method that allows to hook into the mount process.

What i've done was to override the construct and call $this->setTableProperties(); there.

Its wrorking for me and i would be willing to submit a PR but im not sure if it brokes something anywhere else, but as far as I was able to check this method only set some properties based on the configuration file, so it should be a major problem.

Any thoughts?

from laravel-livewire-tables.

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.