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

[Bug]: getSearchPlaceholder() Wrong Return #1951

Open
NastyOOF opened this issue Sep 17, 2024 · 5 comments
Open

[Bug]: getSearchPlaceholder() Wrong Return #1951

NastyOOF opened this issue Sep 17, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@NastyOOF
Copy link

What happened?

Hey, i am new to this Package. I get the following error when i want to load the page:

Rappasoft\LaravelLivewireTables\DataTableComponent::getSearchPlaceholder(): Return value must be of type string, array returned

So i used the Example Component for my first Component:

<?php

namespace App\Livewire\Administration;

use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use App\Models\Languages;

class LanguagesTable extends DataTableComponent
{
    protected $model = Languages::class;

    public function configure(): void
    {
        $this->setPrimaryKey('id');
    }

    public function columns(): array
    {
        return [
            Column::make("Id", "id")
                ->sortable(),
            Column::make("Created at", "created_at")
                ->sortable(),
            Column::make("Updated at", "updated_at")
                ->sortable(),
        ];
    }
}

In my Blade File i run simple this:

@extends('dashboard.overlay')
@section('title', 'Manage Languages')

@section('custom_css')
    <link href="{{ asset('assets/css/custom/dashboard/admin/manageLanguages.css') }}" rel="stylesheet">
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
@endsection

@section('content')

    <livewire:administration.languages-table>

@endsection

How to reproduce the bug

call up the page :c

Package Version

3.4.20

PHP Version

8.3.x

Laravel Version

11

Alpine Version

No response

Theme

Bootstrap 5.x

Notes

No response

Error Message

Rappasoft\LaravelLivewireTables\DataTableComponent::getSearchPlaceholder(): Return value must be of type string, array returned

@NastyOOF NastyOOF added the bug Something isn't working label Sep 17, 2024
@lrljoe
Copy link
Sponsor Collaborator

lrljoe commented Sep 17, 2024

For Livewire v3 - take careful note of how the core Livewire behaves.

Notably, Alpine v3 is bundled in with Livewire v3, so you almost certainly do not need

    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>

In your layout, and this may be causing an issue!

As to why you'd be seeing
"Rappasoft\LaravelLivewireTables\DataTableComponent::getSearchPlaceholder(): Return value must be of type string, array returned"

I can't see you defining setSearchPlaceholder() in your configure() method there. Is that the entirety of your Table where you're experiencing the issue?

Just to rule out anything local, do you have a definition for "Search" locally in your lang files that would return an array?

If you update your configure to match the below, what do you end up with:

    public function configure(): void
    {
        $this->setPrimaryKey('id');
        $this->setSearchPlaceholder('search');
    }

@NastyOOF
Copy link
Author

For Livewire v3 - take careful note of how the core Livewire behaves.

Notably, Alpine v3 is bundled in with Livewire v3, so you almost certainly do not need

    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>

In your layout, and this may be causing an issue!

As to why you'd be seeing "Rappasoft\LaravelLivewireTables\DataTableComponent::getSearchPlaceholder(): Return value must be of type string, array returned"

I can't see you defining setSearchPlaceholder() in your configure() method there. Is that the entirety of your Table where you're experiencing the issue?

Just to rule out anything local, do you have a definition for "Search" locally in your lang files that would return an array?

If you update your configure to match the below, what do you end up with:

    public function configure(): void
    {
        $this->setPrimaryKey('id');
        $this->setSearchPlaceholder('search');
    }

Hey,
First: Thanks for your try to help me!

After I removed Alpine in the code as you described, nothing changed.
I added the "search" Placeholder, but then this Error is coming:

grafik

@lrljoe
Copy link
Sponsor Collaborator

lrljoe commented Sep 19, 2024

Okay, it looks like you're getting conflicts with what your existing localisations.

You must have "Columns" defined in your resources/lang directory.

We'll resume the prefix in a soon-to-be-released version.

Have you published the views? We'd recommend not doing so for 99% of use cases.

@NastyOOF
Copy link
Author

NastyOOF commented Sep 20, 2024

I use the language variables via the database. I don't actually have any that have anything to do with ‘columns’.

But you can publish a fix for it or how do I understand that?

and yeah i published the views i think :c

@lrljoe
Copy link
Sponsor Collaborator

lrljoe commented Sep 22, 2024

The next release will have a new set of views that refer directly to livewire-tables for localisation.

I anticipate releasing it tomorrow

However - you will need to remove your published views before it takes effect.

There is generally no need to publish the views!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants