Coder Social home page Coder Social logo

Comments (17)

milewski avatar milewski commented on August 10, 2024

You cant use a computed attributed like that, MegaFilter needs to know the name of the field in order to work properly, you can change your code to this:

Text::make('Theme', 'theme')->displayUsing(function(){
  return '.....'
})

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Thanks for answering so fast.
I just make what you said but now the values are just "-":
image

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

is themes a relationship? maybe it should be $this->resource->themes->first()->name ? your themes is probably an empty array

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Yes themes is a relationship. It is not empty because all events have at least one theme and before I made the change, the values were displayed well.

Also I just make the change for $this->resource->themes->first()->name but the result is still the same

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

If you simply do this doesnt work?

Text::make('Theme', 'theme')->displayUsing(function(){
  return 'Test Hello world'
})

you see the Test Hello world or still -- ?

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

or you could also try ->resolveUsing() instead of ->displayUsing()

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

If you simply do this doesnt work?

Text::make('Theme', 'theme')->displayUsing(function(){
  return 'Test Hello world'
})

you see the Test Hello world or still -- ?

Exactly:
image

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

or you could also try ->resolveUsing() instead of ->displayUsing()

Same result --> '--'

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

Are you using the use HasMegaFilterTrait; ?

I have a similar setup and its working for me:

image

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Yes, I'm using it:
image

How do you defined you column for that field in megafilter creation?

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

I use it like this:

image

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Mmmh, I put it like you but still the same result...

Maybe I have to update the package? My current version is:
digital-creative/nova-mega-filter": "^0.2.3

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

Maybe that's it, the latest version is v0.2.6

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

I already update it to v0.2.6 but I have the same problem... :(
I don't know if some package could be interacting with megafilter

Also, I see that the resolveCallback is never been executed. I proved to put a dd("Hello World") inside callback but it is never shown on request

from nova-mega-filter.

milewski avatar milewski commented on August 10, 2024

I think the problem might not be with this package in your case, this is my test:

image

<?php

declare(strict_types = 1);

namespace App\Nova;

use App\Models\Client as ClientModel;
use DigitalCreative\MegaFilter\Column;
use DigitalCreative\MegaFilter\HasMegaFilterTrait;
use DigitalCreative\MegaFilter\MegaFilter;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;

class Client extends Resource
{
    use HasMegaFilterTrait;

    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = ClientModel::class;

    /**
     * Get the fields displayed by the resource.
     *
     * @param Request $request
     *
     * @return array
     */
    public function fields(Request $request)
    {
        return [

            Text::make('Test', 'THIS_SHOULD_MATCH')
                ->resolveUsing(static function () {
                    return 'Hello world';
                }),

        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param Request $request
     *
     * @return array
     */
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'columns' => [
                    Column::make('Test', 'THIS_SHOULD_MATCH'),
                ],
            ]),

        ];
    }

}

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Okey, thank you @milewski . Then, I'll have to keep investigating, but I don't know where to start..

from nova-mega-filter.

didix16 avatar didix16 commented on August 10, 2024

Confirmed, I 've updated Laravel and Nova to last versions and now is working as expected.

Thanks for your help @milewski.

from nova-mega-filter.

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.