PHP code example of ruthgeridema / laravel-url-rewrites
1. Go to this page and download the library: Download ruthgeridema/laravel-url-rewrites 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/ */
ruthgeridema / laravel-url-rewrites example snippets
// In routes/web.php
Route::rewrites();
return [
'table-name' => 'url_rewrites',
'repository' => \RuthgerIdema\UrlRewrite\Repositories\UrlRewriteRepository::class,
'model' => \RuthgerIdema\UrlRewrite\Entities\UrlRewrite::class,
'cache' => true,
'cache-decorator' => \RuthgerIdema\UrlRewrite\Repositories\Decorators\CachingUrlRewriteRepository::class,
'types' => [
'product' => [
'route' => 'product',
'attributes' => ['id'],
],
'category' => [
'route' => 'category',
'attributes' => ['id'],
]
],
];
UrlRewrite::create('apple-airpods', 'product/5')
UrlRewrite::create('apple-airpods', null, 'product', ["id" => 5])
UrlRewrite::regenerateRoute($urlRewrite)
UrlRewrite::regenerateAll()
UrlRewrite::regenerateRoutesFromType($type)
use HasUrlRewrite;
public $urlRewriteType = 'category';
protected $appends = ['url'];
UrlRewrite::create('apple-airpods', 'product/5', null, null, 1)
UrlRewrite::create('apple-airpods', 'product/5', null, null, 2)
UrlRewrite::all()
UrlRewrite::find($id)
UrlRewrite::delete($id)
UrlRewrite::update($data, $id)
UrlRewrite::getByRequestPath('apple-airpods')
UrlRewrite::getByTargetPath('product/5')
UrlRewrite::getByTypeAndAttributes('product', ["id" => 5])
bash
php artisan vendor:publish --provider="RuthgerIdema\UrlRewrite\ServiceProvider" --tag="migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="RuthgerIdema\UrlRewrite\ServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="RuthgerIdema\UrlRewrite\ServiceProvider" --tag="nova"