Download the PHP package fomvasss/laravel-url-aliases without Composer
On this page you can find all versions of the php package fomvasss/laravel-url-aliases. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-url-aliases
Laravel URL Aliases
Installation
1) Require this package with composer
2) Publish package resource:
- config
- migration
3) Run migrate:
Integration
1) Add to your model next trait: Fomvasss\UrlAliases\Traits\UrlAliasable
This trait have next relation-method:
urlAlias()
- related UrlAlias model
Do not forget use
with('urlAlias')
in your models when you get list!
2) Add the middleware to Http/Kernel.php
:
Usage
Facade
\Fomvasss\UrlAliases\Facades\UrlAlias::route('article.show', $article)
\Fomvasss\UrlAliases\Facades\UrlAlias::current()
Helper functions
route_alias()
- works the same way as Laravel helperroute()
url_alias_current()
- return alias path (or system path if alias not exists)prepare_url_path()
- return path for URL: https://your-site.com/my-first-page/example/ -> my-first-page/example
Examples usage
-
routes/web.php
: app/Http/Controllers/Front/ArticleController.php
:
In
UrlAlias::current()
(route_alias()
) second argument (if array - first index) may beid
or the instanceof\Illuminate\Database\Eloquent\Model
(likeroute
Laravel helper)
Use localization URL's (dev)
For use localization url's, you need do next steps:
1) Add to Http/Kernel.php
next middleware:
2) Set in config/url-aliases.php
: 'use_localization' => true,
3) Uncomment needed locales in config/url-aliases-laravellocalization.php
and set other params
4) Make or change your home page (root) routes, for example:
5) Save aliases for entity and set locale:
6) Use facade UrlAliasLocalization
and next methods (like in mcamara/laravel-localization):
Links
All versions of laravel-url-aliases with dependencies
illuminate/support Version 5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0
illuminate/database Version 5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0