PHP code example of outerweb / filament-link-picker
1. Go to this page and download the library: Download outerweb/filament-link-picker 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/ */
outerweb / filament-link-picker example snippets
use OuterWeb\FilamentLinkPicker\Filament\FilamentLinkPicker;
class FilamentPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentLinkPickerPlugin::make(),
]);
}
}
use Outerweb\FilamentLinkPicker\Entities\LinkPickerRoute;
FilamentLinkPickerPlugin::make()
->combineLocalizedRoutesUsing(function (LinkPickerRoute $route): LinkPickerRoute {
// Imagine your routes are named like `en.your-route` and `nl.your-route`
// We want to combine these routes so that the link picker only shows one option for `your-route`
return $route->name(Str::after($route->name(), '.'));
});
use Outerweb\FilamentLinkPicker\Entities\LinkPickerRoute;
FilamentLinkPickerPlugin::make()
->buildLocalizedRouteUsing(function (string $name, array $parameters = [], bool $absolute = true, ?string $locale = null): ?string {
// If you use our `outerweb/localization` package,
// You can use the `localizedRoute` helper.
return localizedRoute($name, $parameters, $absolute, $locale);
});
use Outerweb\FilamentLinkPicker\Casts\LinkCast;
class YourModel extends Model
{
protected $casts = [
'link' => LinkCast::class,
];
}
use Outerweb\FilamentLinkPicker\Facades\LinkPicker;
$link = LinkPicker::dataToLinkEntity(array $data);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.