redirect() is one of the most used and popular helper function. This function redirects users to different URLs of the website. By using this method, we can redirect the user to pages with or without data.

Redirect to different URL

This is the most and simplest form in which redirect method is used. We can redirect a user to homepage by simply using method below:

return redirect('/');

Users can also pass parameters inside redirect method. The parameters given in the method will be added to URL of base application.

return redirect('contact');

Likewise, users can also pass more parameters:

return redirect('user/profile');

back() in Laravel

If the user wants to perform some sort of tasks and redirect back to the same page then the user can use back(). This method is also really helpful. …

In this article, we’ll take a look at the new blade components that is available in laravel 7. Laravel 7 introduced a new syntax for creating blade components. Therefore, allowing developers to create more expressive and reusable components.

Technically, blade components already exist inside laravel but laravel 7 brings brand new class-based component, anonymous component, and a new way of displaying components in your frontend HTML markup.

Creating New Blade Components

If we look at the list of available artisan commands, you’ll find a new make:component artisan command. You could also use --help flag to check optional parameters.

For example, let’s create a sample component called Sidebar.

Routing allows the user to route application requests to its appropriate controller. Laravel has inbuilt API which is really helpful and time saving. Hence, it is important for newcomers to know and extend their knowledge about routing.

Users can learn about routing technique basics from here. Please go through the link to get more familiar with routing.

Here are a few tricks that can help you to use routing in Laravel:

Using Custom Namespace

Users can define namespace for a group of routes using fluent routing API.

Route::namespace('Admin')->group(function () {
// Controllers Within The "App\Http\Controllers\Admin" Namespace

Run the command given below to create controller in…

This tutorial will show you how to implement Full-Text search capability in Laravel 7 MySQL v5.7.26. Although Laravel currently doesn’t support FULLTEXT indexes, there’s a easy workaround to implement this.

Points to note about Full-Text Search

MySQL has support for full-text indexing and searching:

  • A full-text index in MySQL is an index of type FULLTEXT.
  • Full-text indexes can be used only with MyISAM tables. (In MySQL 5.6 and up, they can also be used with InnoDB tables.) Full-text indexes can be created only for CHAR, VARCHAR, or TEXT columns.
  • A FULLTEXT index definition can be given in the CREATE TABLE statement when a table is created, or added later using ALTER TABLE or CREATE INDEX. …

When your laravel application is slow, caching can be of the best way to gain performance. Additionally, laravel provides bunch of built-in caching methods to handle cache in different ways like Redis, Memcached and file cache.

Caching can minimize your page load time drastically and make you application way faster. Laravel’s performance by default can be slow if you are executing a lot of eloquent queries at page load. Afterall, caching most of these heavy queries can lift a some load from your server and makes your application load faster.

In this tutorial, we will use query caching package, thus making super easy to cache your query results for an adjustable amount of time. …

Laravel Eloquent ORM provides a whole lot of useful functionality that allows you to work with your database tables and relationships using an eloquent expressive syntax.

So, In here are some of the features which you might often reach out for ease of use and cleaner code in your laravel project.

1. Finding first record or records

Here’s an example of finding a post with id.

// Instead of this
$post = Post::find($id);
if(!$post) {
// Do this
$post = Post::findOrFail($id);

Or, you can even find multiple records at once by passing array of ids as second argument.

$posts = Post::find([1,2,3]);

Even specify id with the fields to select as the second argument. …

When developing a laravel project, developers often find themselves writing and repeating same trivial codes. Whether if its making a model, controller or view etc.. and many others files that you would normally create in a laravel project.

Although, artisan commands can be helpful creating files and components for your project, these are mostly just blank classes that you need to fill in with your logic.

In comes blueprint, this package lets you generate laravel codes a lot faster using a draft file. …

Sometimes, there might be a situation where you need to insert a lot of test data into the database. Usually for testing purposes and performance in laravel.

However, seeding a huge amount of records can take an exceptionally long time and is not ideal when you’re in a state where you have to frequently seed databases.

So, let’s try to improve the seeding time so that we won’t have a hard time waiting for it to finish.

Generating Random Data

Below, is the a simple PostFactory.php file for generating fake data using Faker.

<?php/** @var \Illuminate\Database\Eloquent\Factory $factory */use App\Post;
use Faker\Generator as…


Laravel Project

( Online resource for tutorial articles and open source projects for learning laravel framework.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store