We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I need to search with translatable field
public static $searchRelations = [ 'category' => ['title'], ];
title has translatable property of Spatie package
public $translatable = ['title'];
The text was updated successfully, but these errors were encountered:
I need to search with translatable field public static $searchRelations = [ 'category' => ['title'], ]; title has translatable property of Spatie package public $translatable = ['title'];
create a new class that implements search im not using spatie package and dont know how it works.
this is an example how i search on laravel nova actions using moprh on the target
class MorphSearch implements Search { /** * Searchable columns. * * @var array */ protected $morphRelation; /** * Instantiate a new search query instance. * * @param array $columns */ public function __construct(array $morphRelation) { $this->morphRelation = $morphRelation; } public function apply(Builder $query, string $relation, string $search): Builder { foreach ($this->morphRelation as $morphClass => $columns) { if (class_exists($morphClass) && is_subclass_of($morphClass, Model::class)) { $query->orWhereHasMorph($relation, [$morphClass], function ($query) use ($columns, $relation, $search) { return (new ColumnSearch($columns))->apply($query, $relation, $search); }); } } return $query; } }
nova resource
... public static function searchableRelations(): array { return [ 'target' => new MorphSearch([ 'App\Models\Role' => ['name'], 'App\Models\User' => ['name', 'username', 'email'], 'App\Models\Permission' => ['name'], 'App\Models\Invite' => ['email'], ]) ]; } ...
Sorry, something went wrong.
No branches or pull requests
I need to search with translatable field
title has translatable property of Spatie package
The text was updated successfully, but these errors were encountered: