Category: Laravel

Get next id in auto generated field in Laravel

You can use the following code to get the next id of the auto generated field of the table in Laravel,

Read more

Redirect to specified route after logout – Laravel

Redirect after logout In default Laravel app, once you logout it will redirect to the home page. But you can change where to redirect after you log out. Never edit the core files located at your vendor folder that will override when you update the Laravel versions In Auth\LoginController you have the following trait You […]

Read more

Laravel Gate::define easy code

You can us the following code define your all gates. Permission table has got the control name,action and models This code is ok for small web application. If your project is gig with several user role this code is not going to work because you have to use lots of If – else condition check […]

Read more

Fetch select fields on a hasMany relation

https://stackoverflow.com/questions/30022038/fetch-specific-fields-on-a-hasmany-relation

Read more

Set Selected on Select Form Control in Laravel

In your blade file, you have to set the select option when you are in edit mode. You need to get output like this To get the above output you can use the following code

Read more

Laravel- Call function of a Model in a blade file

You have a category.blade.php file and you want to call a function name someFunc() inside the Category model Inside your category.blade.php you can call the function {{$model->someFunc()}}

Read more

Laravel like in Eloquent

If you want to run query with Like statement using Eloquent you can follow the following example

Read more

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8001/api/categories/?page=undefined. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Error: “Network Error”    createError createError.js:16    handleError xhr.js:83 This happens when I run the Vue app from localhost to fetch the data from Laravel application running on http://127.0.0.1:8001/api To fix the you can use the following steps 1 Install […]

Read more

Laravel Lifecycle Overview

This is Laravel Life cycle overview for developers. You can get basic understanding when you make a request to Laravel App

Read more

Laravel 5 – Remove public from URL

When you install Laravel in your server you will get URL like this to list your customers http://yourdomain.com/public/customers I need somethig like this http://yourdomain.com/customers This is the solution. You have to do two things to remove “public/index.php” from the URL 1 Rename server.php in your Laravel root folder to index.php 2 Copy the .htaccess file […]

Read more