Tag : Route


How to get current controller name in view Laravel 5?

If you require to get current controller name in your view file or in your middleware or your serviceprovider etc. you can get your controller details from current route like UserController, HomeController ect. you can also get full path of controller file. Laravel getAction() through we can get whole array of current route details, in this example i get current controller in my auth middleware, if you require on your view file or other place then you can simply get. So, let's see example how you can get controller name in auth middleware. <strong>Example: app/Http/Middleware/Authenticate.p.....

By Hardik Savani | July 27, 2016 | | 1163 Viewer | Category : Laravel
READ MORE

How to create and use Middleware in Laravel 5?

Laravel is the best framework in PHP todays. Laravel framework provide saveral functionality and you can also find from this site. But now in this post you can learn how to create custom middleware as filter in laravel 5 example and how to use middleware in laravel 5. In this example you can learn how to add middlware from scratch in your laravel application. In this example i added middleware for check if user is admin then it can open someroute like ACL. So i added <strong class="path">id_admin</strong> column in my users table if use have is_admin = 1 then it can access "admins" route. So .....

By Hardik Savani | April 24, 2016 | | 1706 Viewer | Category : Laravel
READ MORE

How to get current route name in Laravel 5?

Whenever you need to get current route name then you can get using Request or Route facade. I give you two example one for using Route facade and another for Request facade. so you can get route name both way and how you can see both example. <strong>Using Request:</strong> <pre class="prettyprint lang-php"> $routeName = Request::route()->getName()); print($routeName); </pre> <strong>Using Route:</strong> <pre class="prettyprint lang-php"> $routeName = Route::getCurrentRoute()->getPath(); print($routeName); </pre>

By Hardik Savani | April 10, 2016 | | 1768 Viewer | Category : Laravel
READ MORE

How to redirect route with querystring in Laravel 5?

Most of time, we work on back-end and we require to redirect route or url from controller with pass query string parameter. so laravel provide very simple way to pass query string parameter with redirect route. In following example you can see how it is possible. In Bellow example you can see i did added highchart() function for route haddle. in that function i redirect "home" route with 2 parameter as query string like id and itemid, so url will be like this way: <pre>http://test.hd/home?id=2&itemid=3</pre> And controller function will be this way: <strong class="example">Example:</strong> .....

By Hardik Savani | April 8, 2016 | | 2670 Viewer | Category : Laravel
READ MORE

How to generate route with query string parameter in Laravel 5?

Whenever you require to add query string parameter in link url, i mean in route then you generate link with query string parameter using Laravel 5 URL facade. most of new developer doing this way: <pre class="prettyprint lang-html"><a href="{{ URL::route('home') }}.'?id=1&test_id=2'">Test</a></pre> But you should do it that this way, bellow example you can see how it done. <pre class="prettyprint lang-html"><a href="{{ URL::route('home',['id'=>'2','test_id'=>'3']) }}">Test</a></pre>

By Hardik Savani | April 7, 2016 | | 1706 Viewer | Category : Laravel
READ MORE

Ajax - Cross-Origin Request Blocked in Larave 5?

When i was working on my laravel 5 project and i was making backend API, i created successfully but when front-end developer call API which i made. It's return like: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://learnl52.hd/register. (Reason: CORS header 'Access-Control-Allow-Origin' missing)." and i did try to how to solve this issue. I did also try with jquery and angularjs from backend but result nothing always. At last i did found how to solve this issue, i made one middleware that allows to Cross-Origin Request in your laravel appli.....

By Hardik Savani | March 30, 2016 | | 4060 Viewer | Category : Laravel jQuery AngularJS Ajax
READ MORE

How to get Query Strings Value in Laravel 5?

If you want to get Query string value then you can get using Request Facade OR Input Facade in larave 5. But if you was working native PHP then we can get $_GET method. In following example you can easily get parameter value. <strong class="example">URL Example:</strong> <pre>http://text.com/wall?id=23&name=hdtopi</pre> In above query string, you want to get query string value for example id and name. you can get through bellow example. <strong class="example">Route Example:</strong> <pre>Route::get('wall', 'WallController@wall');</pre> <strong class="example">Controller Example:</strong> <pr.....

By Hardik Savani | March 29, 2016 | | 2899 Viewer | Category : Laravel
READ MORE

Laravel 5 clear cache from route, view, config and all cache data from application

In this post i would like to share my experience and solution. when i was working on my laravel e commerce website with gitlab. I was fetching one issue suddenly my view cache with error during development. i did try lot to refresh and something other but i can't see any more change in my view, but at last I did resolve my problem using laravel command so, let's see i added several command for clear cache from view, route, confir etc. <strong class="example">Reoptimized class loader:</strong> <pre class="prettyprint lang-php">php artisan optimize</pre> <strong class="example">Clear Cache fac.....

By Hardik Savani | March 22, 2016 | | 4383 Viewer | Category : Laravel
READ MORE

    Laravel 5 - How to get difference of time in minutes?

    Laravel 5 - How to get difference of time in minutes?

    Open Post

    PHP - jquery ajax crop image before upload using croppie plugin

    PHP - jquery ajax crop image before upload using croppie plugin

    Open Post

    Laravel 5 - line chart example code using google charts API

    Laravel 5 - line chart example code using google charts API

    Open Post

    How to retrieve number of twitter followers count without authentication or api ?

    How to retrieve number of twitter followers count without authentication or api ?

    Open Post

    Laravel 5 generate sitemap using roumen/sitemap package Example

    Laravel 5 generate sitemap using roumen/sitemap package Example

    Open Post

    How to add CKEditor with image upload using KCFinder in PHP Example Code?

    How to add CKEditor with image upload using KCFinder in PHP Example Code?

    Open Post