yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Appends array is searched for in columns #66

Closed Yorannn closed 6 years ago

Yorannn commented 6 years ago

Currently when you use the protected $appends array on your model the plugin searches for these names in your database as well resulting in Column not found: 1054

johankladder commented 6 years ago

I know it's closed, but I had the same issue. Solved it by applying this function in my class:

public function toSearchableArray()
    {
        $array = $this->toArray();

        unset($array['pngs']);

        return $array;
    }

... where 'pngs' is a appended field.

jerrebm commented 6 years ago

Why was this closed? 🤔

This bug hasn't been fixed yet. Although @johankladder's workaround works, having the search driver ignore $appends value would be the correct solution. $appends only defines accessors to append to the model's array form, and has nothing to do with the actual database structure.

CraftyDlx commented 1 year ago

Tried to use Scout with the database engine in my Laravel 9 app using appends and got this error. I'm confused, Scout is listed as official package for Laravel 10 even, yet a 4,5 years old bug still exists. Could someone explain to me why that is and if it's recommended at all using Scout? Seems like riding a dead horse but I'm open to other views.