Skip to content

Tag: laravel

Laravel active menu item for url included parameters

I’m trying to set active class in my list item, but it doesn’t work. My code in blade: So, if I write: li class=”@if(getRouteName() == ‘site@index’){{ ‘active’ }}@endif” , it works nice, but in my case the problem is that I want to get ‘active’ class…

Convert to Laravel exception?

Currently in a package, it has HttpException exception Is there a way to to convert it Laravel HttpResponseException uses without touching that exception from the package? Answer You can catch that exception and rethrow it. In your app/Exceptions/Handler.php file. Edit: I haven’t tested this but accordi…

Laravel mysql avg() function

I am using Laravel on developing my new app. I have initiated average function on a rating column in my database table and now I am just curious how could I make the average value from “3.3333” into “3.3”. Answer You can use php’s inbuilt functions for rounding. In this case, you…

Laravel HasMany across multiple connections

I want to retrieve Offers related to Offer on a second table offer_related because I can’t change the schema of the Offer table. I have two databases on different connections, offers on one, and offer_related on another. For the sake of argument, I’m going to name databases as follows for clarity …