Search code examples
phphtmllaravelvoyager

How can I filter values from table to use them at dropdown control?


I'm trying to use local scopes to filter select options. I found this document Using local scopes with Voyager. It says you can use functions called scopes at my model and specify those functions at my relationship's options, so that's what I did, but it doesn´t work.

My Model is

class Materiale extends Model

{ protected $fillable = [ 'id', 'nombre', 'precio_mt', 'tipo'

];

public function scopeSustrato($query)
{
    return $query->where('tipo', 'SUSTRATO');
}

public function scopeAcabado($query)
{
    return $query->where('tipo', 'ACABADO');
}

public function scopeOtro($query)
{
    return $query->where('tipo', 'OTRO');
}

}

and my Relationship options are

enter image description here

As you can see at the picture, there I'm using

{
"scope": "acabado"

}

I tested The scope with the model directly and it works. So what's happening? Is it a bug of voyager?? I have 1.3.1 installed.

Can you give me a clue? Right now nothing happens, not even an error...

Thanks in advance.


Solution

  • I fixed the issue. Just upgrade voyager 1.3.1 to 1.4.2 the current version.