letrunghieu / active Goto Github PK
View Code? Open in Web Editor NEWThe helper class for Laravel applications to get active class base on current route
Home Page: https://www.hieule.info/tag/laravel-active/
License: MIT License
The helper class for Laravel applications to get active class base on current route
Home Page: https://www.hieule.info/tag/laravel-active/
License: MIT License
I'm encountering a use case where I need a pattern to match except for a specific URL. For example, I want the pattern 'users*'
to match except for 'users/all'
. If I'm not mistaken, this is not possible yet with this package, so I'm looking for feedback whether it would be useful to add this.
Thanks!
I don't know why exactly, but composer update spends a lot (lot lot) a time reading and writing cache from watson/active package.
It's really sad because as a conflict it should simply be ignored.
I still don't know what you can do about it, but maybe a simple warning should be better than this network lag on each composer update.
A nice feature would be to have the possibility to add a third argument that would be returned in case the route does not match the given pattern. For example:
# Return string 'selected' if current URI is /foo or /bar or return string 'not-selected' if current URI is not /foo and not /bar
Active::pattern(array('foo', 'bar'), 'selected', 'not-selected');
Would this be something you would consider to add? I'd be glad to help with a pull request!
Hi! I think that this package is nice.
I did find an error in your documentation at your website though. Just a mistake.
https://www.hieule.info/products/laravel-active-version-3-released/
It is under the header:
Check the route parameter value
- Use the alias:
Active::checkRouteParam($key, $value)
- Use the application container:
app('active')->checkRouteParam($key, $value)
- Use the helper function:
if_route_pattern($key, $value)
The third line is wrong and should be:
if_route_param($key, $value)
the error is _pattern instead of _param like it should be
Hi,
I followed your documentation and when just simply trying the following code I got the error:
Argument 1 passed to if_route() must be of the type array, string given
active_class(if_route('xxx.xxx'))
I have a route named xxx.xxx
...
You should fix your documentation.
Thank you
If I have bound the route param to route, eg: /{course}/{episode}, and episode bound with episode model
if_route_param('episode', $episode)
will return null.
$this->route->parameter($param)
will return the episode model, and it don't equal $episode model
Hi @letrunghieu
Would it be possible to update your package(s) to support the newly released Laravel 7?
Thanks!
Hi, is this can use for laravel 5.6?
Best Regards,
Is this package going to be updated for Laravel 5?
I think it would be a good idea to include the route parameters and not only the route name.
Lets say we need to set an active class for the route admin/product-types/{product_types}/categories
.
We can do something like (not a very good example but hopefully you get the point):
Active::route(['admin.product-types.categories.index' => [$product_type->id]])
Please add a Active::method('method') similar to Active::controller('Controller') which will return a Boolean. :)
Hello,
Since I upgraded active to the last version (documentation worth an upgrade), I cannot tail my production logs anymore : http://laravel.io/bin/Qkyx1
It seems Active triggers its method, but cannot find any router (which is totally logical since I use CLI).
BTW, Thank you so much for this useful package !
Hi,
My laravel app uses a global layout and Active::pattern
in order to render my global menubar.
Since I try to implement my own 404 error pages, I met a bug :
Everywhere I use pattern, instead of returning active
or false, Active facade seems to render recursively a 404 error page itself.
Did i miss something ?
what if i wanna change the class name ? i want to use menu-activr class instead of active how to make this ?
Now that Laravel 5.3 has officially been released, it would be awesome if this package could be updated to be installable in new projects.
Currently, running composer require hieu-le/active
in a new Laravel project errors out with dependency failures.
Thanks, dude! 😃
Will this package support Laravel 6.0?
Thanks for the script.
when I'm on /dragonfire1119 route and try
Active::pattern(Auth::user()->username);
it doesn't return active.
Request::is(Auth::user()->username) ? 'active' : ''
This works just fine.
Hi,
Is it possible to make this package compatible with Laravel 4.2? The current composer requirements don't seem to allow Laravel 4.2.x.
Thanks
I'm going to /
but I'm also calling api/v1/posts
which makes
uri
GET api/v1/post
name
api.v1.post.index
It changes the uri and name so the only thing that works right now is
{{ Request::is('/') ? 'active' : '' }}
I'm trying to call Active::route('routename')
in my view and get:
Non-static method HieuLe\Active\Active::route() should not be called statically, assuming $this from incompatible context ...
I tried to just rewrite the functions with static methods but that led to the router needing to be instantiated so I wasn't sure what to do from there.
The Active::pattern
method will return wrong result if the current rout has ant parameters. This is found when I am trying to resolve issue #2.
In the current version, you still have a reference to app->share
in your service provider.
I see that the development version is using the app->singleton
method. Could you release an update to get compatibility with L5.4?
Hi @letrunghieu,
Thanks for creating this! When visiting a 404 page, I get the following error:
TypeError
in_array(): Argument #2 ($haystack) must be of type array, string given (View: navbar.blade.php)
Any chance you could fix this please, only happens for if_route_pattern
I've just updated my site to Laravel 5.3 (I know it's not officially released yet, but it's now RC1). I'm now getting the above error.
Maybe something to do with the updated RouteServiceProvider but I'm no expert.
I just tried to update my active version from 2.3.x
to the latest release 3.x
.
Well, this can be 'painful' if you work on a big project with a lot of uses of the package.
Active::Pattern
as example).string
as parameter. Only an array
even if you only have one single value to check with. So after updating the methods, you'll need to update your string
parameters to arrays
. It has been reported at #28active
' string defautly, but a true/false
(1/0) as explained at #29After discovering the implication of thisupdate, I decided to move back to my previous 2.x version. I think the string/array
or the 'active
' issues could be updated to match the functionnal 2.x behavior, but i may be wrong.
Anyway, 3.x updates seems pretty cool, from what i've tested and read.
ps: some infos could be partially or fully wrong, be sure that i love this awesome package !
I use L5, added in composer.json
"hieu-le/active": "~2.0"
Append this line to your providers array in config/app.php
'HieuLe\Active\ActiveServiceProvider',
Append this line to your aliases array in config/app.php
'Active' => 'HieuLe\Active\Facades\Active',
L5 return:
BindingResolutionException in Container.php line 872: Unresolvable dependency resolving [Parameter #0 [ $app ]] in class Illuminate\Support\ServiceProvider
Some libraries use a complex combination of parameter's values.
For example:
RequestCriteria of andersao/l5-repository
http://prettus.local/users?filter=id;name
The values (id and name as well as others) of filter could be dynamic combination.
Can not easily be matched by if_query.
I'm not sure if this is new for Laravel 5 or what, but specifically with this code
Active.php
public function action($actions, $class = 'active')
$routeAction = $this->_router->currentRouteAction();
$this->_router->currentRouteAction() returns the full path of the action
i.e. (App\Http\Controllers\MyController@index rather than MyController@index)
So when using Active::action('MyController@index') it will fail when following the documentation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.