1. Go to this page and download the library: Download matheusmarnt/scoutify library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
matheusmarnt / scoutify example snippets
public function globalSearchTitle(): string { return $this->title; }
public function globalSearchSubtitle(): ?string { return $this->author; }
public function globalSearchUrl(): string { return route('articles.show', $this); }
public static function globalSearchGroup(): string { return 'Articles'; }
public static function globalSearchLabel(): string { return 'Articles'; } // UI chip label
public static function globalSearchIcon(): string { return 'heroicon-o-document-text'; }
public static function globalSearchColor(): string { return 'blue'; }
> public static function globalSearchIcon(): string { return 'ri-customer-service-2-fill'; }
> public static function globalSearchIcon(): string { return 'tabler-home'; }
>
> use Matheusmarnt\Scoutify\Facades\Scoutify;
>
> Scoutify::types()->iconPrefix('ri-');
>
use Laravel\Scout\Builder;
public function globalSearchBuilder(Builder $builder, string $query): Builder
{
return $builder->where('published', true);
}
use Matheusmarnt\Scoutify\Authorization\VisibilityRule;
use Matheusmarnt\Scoutify\Contracts\HasGlobalSearchVisibility;
class Article extends Model implements GloballySearchable, HasGlobalSearchVisibility
{
use Searchable;
public function globalSearchVisibility(): VisibilityRule
{
return VisibilityRule::make()
->visibleToGuests() // expose to non-authenticated visitors
->orWhenAuthenticated() // OR when authenticated +
->policy('view') // passes registered policy
->orPermission('view-articles') // OR has Spatie permission
->orRole('admin') // OR has Spatie role
->orAttribute('is_active'); // OR has boolean attribute true
}
}