1. Go to this page and download the library: Download vlados/laravel-unique-urls 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/ */
class MyModel extends Model
{
use Vlados\LaravelUniqueUrls\HasUniqueUrls;
public function urlStrategy($language,$locale): string
{
return Str::slug($this->getAttribute('name'),"-",$locale);
}
public function urlHandler(): array
{
return [
// The controller used to handle the request
'controller' => CategoryController::class,
// The method
'method' => 'view',
// additional arguments sent to this method
'arguments' => [],
];
}
public function view(Request $request, $arguments = [])
{
dd($arguments);
}
$model = new TestModel();
$model->disableGeneratingUrlsOnCreate();
$model->name = "Test";
$model->save();
public function urlHandler(): array
{
return [
// The Livewire controller
'controller' => CategoryController::class,
// The method should be empty
'method' => '',
// additional arguments sent to the mount() function
'arguments' => [],
];
}
class LivewireComponentExample extends Component
{
private Url $urlModel;
private array $url_arguments;
public function mount(Url $urlObj, $arguments = [])
{
$this->urlModel = $urlObj;
$this->url_arguments = $arguments;
}
public function render()
{
return view('livewire.view-category');
}
}