Tag

Laravel

Browsing

Laravel 5.6 CRUD tutorial In this tutorial We will cover Laravel Listing, create, update, delete the basic application functionality. All Laravel application must have Larave CRUD tutorial functionality.  I will teach you how to create Laravel CRUD step by step. This tutorial is useful for Laravel beginner. Because In this tutorial I will cover all basic concept of Laravel for starting an application.

There are many Laravel CRUD generator tutorial but it is not meaning for the beginners. So, For the Beginners user, I am creating this Laravel CRUD Tutorial.

Today, We are going to learn Laravel 5.6 CRUD tutorial step by step. First of all, We are starting from going to install Laravel application.

Laravel 5.6 CRUD tutorial

We will follow the steps of the creating the Laravel 5.6 CRUD tutorial

  1. Laravel installation
  2. Database configuration
  3. Integrate AdminLte theme
  4. Write the Routes
  5. Generate migration files
  6. Create the Model
  7. Generate Controller
  8. Create the Views files

Finally, We are ready with the steps we will follow these steps for creating CRUD Tutorial.

We are going to create the category module for CRUD tutorial. Let’s start the CRUD tutorial

1 ) Laravel installation

First of all, We are going to install Laravel using composer by following the command

Follow this tutorial for installing Laravel and getting more detail about Laravel Installation.

Finally, We are ready with the Laravel Application. Now, We are going to configure Database.

2 ) Database configuration

After, Creating the  Laravel project open the configuration file “.env” then change the database configuration like

Next, We are going to run migration for generating Laravel tables

If you getting an error by following migration command like “1071 specified key was too long” then just follow this tutorial.

Finally, We are ready with the Database configuration. Now, We are going to integrate AdminLTE theme.

3 ) Integrate AdminLte theme

Finally, We are going to integrate AdminLTE theme, But I create the different tutorial for integrating AdminLTE admin theme. Because I want to make this tutorial simple and sort. So, Please follow this tutorial for integrate AdminLTE theme.

Before, Going to the next step make sure the AdminLTE theme is install properly.

4 ) Write the Routes

Finally, We are ready with the Laravel application with admin theme. Now, First of all, We are going to create the routes for our CRUD tutorial. Let’s open the routes/web.php file.

We will create the route group for all admin module URL are located on the same prefix “admin”. Also, We have namespace “Admin”. So, our Controller files are stored in the Admin folder.

5 ) Generate migration files

Now, Let’s create the migration for the category table. We have to create the category table for storing the data in a database. We generate migration file using artisan command like

After, Follow this command the Laravel generate migration for the category table. Laravel generate migration file at database/migrations/ You will see the new migration file for a category on migrations folder. Let’s open the category migration file and change the code like

Finally, We are ready with the migration table. So, Let’s run the migration first by the following command

The migrate command will create the category table into the database. So, We are ready with the category table. Now, we are going to create the Controller.

6 ) Create the Model

Finally, We are ready with the category table. Now, let’s create the Model file for the category table by following the command.

So, Laravel generates Model file inside app folder. You will find the category model file at app/Category.php  let’s open the model file then write the code like

Finally, We are ready for the Category Model. So, We are going for creating the controller file.

 7 ) Generate Controller

We are going to creating the CategoryController file. As per describe on a route. We are using the namespace Admin on the route group. So, We have to create the Controller file inside the Admin folder like “App\Http\Controllers\Admin”. So, Let’s create the Category Controller by the following command

Finally, We are ready with the Category Controller. So, Open the controller and write the code like

Finally, We are with the Category Controller. Now, We able to perform the insert, update, delete operation using category controller.

8 ) Create the Views files

Now, We are going for creating the view files. Laravel use blade template for the view file. We can create the user interface using view file. We are going to create three view files for insert, create, update.

  1. index.blade.php
  2. create.blade.php
  3. edit.blade.php

Create all those files inside “resources\views\admin\category” folder step by step.

First of all, We are going to creating the listing. So, let’s open the “resources\views\admin\category\index.blade.php” file and write the code like

Now, we are going to create the insert category form. So, let’s open the “resources\views\admin\category\create.blade.php” file and write the code like

Now, we are going to create the update category form. So, let’s open the “resources\views\admin\category\edit.blade.php” file and write the code like

We are ready with the Laravel CRUD tutorial. Now we can run the Laravel application and check the CRUD example. Follow the command for running laravel application.

Now, check the category module using this URL.

The output something look like

Laravel Crud

I hope this Laravel 5.6 CRUD tutorial is helpful for you. We are creating the reusable Laravel CRUD Code. you can reuse the module by just changing some labels on Controller file. If you face any issue by following this tutorial please write the comment below.

 

Today, I am going to tell you about the “Laravel Call undefined method lists Illuminate\Database\Query\Builder::lists()” error and going to share solutions with you.

When I am working with Laravel many times I used the eloquent “lists” method for getting the lists of the names like the country name with the ID as the key like.

When I am trying the use the lists method on the laravel 5.3 I am getting the error  “Laravel Call undefined method Illuminate\Database\Query\Builder::lists()” like

Laravel Call undefined method lists

When I search for this error I found that the “lists” method is removed from the Laravel 5.3. Now, we get the same lists data using pluck method form the Laravel 5.3 like

Finally, We are getting the solution use pluck method instead of the lists. Still, if you face any issue write the comment below.

Many web servers don’t allow to send mail directly from the server for the security purpose. So, Today we are going to learn Laravel SMTP send mail using Gmail SMTP. Also, Let’s see how we can send mail using Laravel Gmail SMTP. We can easily set up the SMTP driver for the Laravel application.

First of all, We are going to install Laravel step by step if not installed

Laravel SMTP send mail using Gmail SMTP

Once we are ready with Laravel let’s start the Laravel SMTP setting using Gmail SMTP step by step. Let’s open the “.env” file then follow the instruction

  1. First, we need to change the MAIL_DRIVER to smtp
  2. We need to set up the MAIL_HOST like “smtp.gmail.com” or “mail.domainname.com
  3. We need to set up the MAIL_PORT correct port for TLS and SSL like 587, 445, 25 etc…
  4. provide the username for the authentication MAIL_USERNAME
  5. provide the password for the authentication MAIL_USERNAME
  6. set up the encryption MAIL_ENCRYPTION for the authentication SMTP detail

After, setting up the server detail “.env” look like

Finally, We are ready with the SMTP If you are using Gmail as SMTP server then make sure don’t forget to enable Less Secure app.

Now, let’s check Laravel SMTP is working on not by sending the mail using Laravel like.

Now, let’s create the email template laravelhive.blade.php into the “resources/views/emails” directory.

Finally, We are ready for sending the testing email by following “http://localhost:8000/send-mail” URL.

If you face any issue with sending mail using Laravel SMTP write the comment below.

Today, We are going to learn How to integrate admin theme AdminLTE Laravel. We are using Acacha AdminLte Laravel package As a Laravel Admin panel. Also, AdminLTE is an open source admin panel theme. So, We can easily use AdminLTE with Laravel as an admin panel. Acacha AdminLTE laravel package switch default Laravel scaffolding/boilerplate to an AdminLTE template and Pratt Landing Page with Bootstrap.

First of all, We are going to install Laravel, Follow this tutorial for installing Laravel.

After, Installing the Laravel let’s generate the auth scaffolding and migration using artisan command like

Also, If you face any issue when you run migration like “1071 specified key was too long” just follow this tutorial.
Finally, We are ready with the Fresh laravel installation Now, We are going to install AdminLTE with Laravel.

AdminLTE Laravel 5.6

We are going to install AdminLTE admin theme with Laravel 5.6 using Acacha AadminLTE Laravel Package. First of all, We are going to install Acacha AdminLTE package using composer like

Once the Acacha AdminLTE package is installed  We need to register Service Provider and Aliases to the Laravel application so let’s open the config/app.php file and add Service Provide entry first

Now we are going to register Aliases

After, Register Service Provides and aliases We need to publish Acacha AdminLTE package configuration and assets using artisan command like

Finally, We are ready with the AdminLTE Laravel now let’s run the laravel application by the following command

If you face any issue to Integrate AdminLTE Laravel 5.6 please write the comment. Also, the improvement and suggestions are always welcome please write the comment.

One day I install Laravel 5.6 When I am going to create a migration for the Laravel application. Then I run Laravel migration command I got an error like 1071 specified key was too long max key length is 767 bytes. I find the solution why I got Laravel 1071 specified key was too long error when I run the migration.

Since Laravel 5.4 change the default database character set to “utf8mb4” for includes support for storing emojis. This only affects If you running MariaDB or older versions of MySQL. You may hit this error when you are running migration command.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

PDOException::(“SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes”)

As per Laravel 5.4.* documentation, You need to set default string length on Boot method for the resolving this issue.

Laravel 5.6 – 1071 specified key was too long

First of all, Open the App Service Provider at “app/Providers/AppServiceProvider.php” then follow below steps.

After, applying that solution everything is working fine. Still, if you face any issue write the command below.

Today, We are going to learn about Laravel clear cache. Laravel create the cache of Route, View, Config file data. When I working on a project suddenly I get a fatal error on Laravel view file. After, Resolving that issue on view file I see the error still exists in the view file. The issue is the Laravel cache my view file. I resolve that issue by clearing Laravel cache. So, I want to share with you How to clear laravel cache.

We can clear Laravel cache using artisan command using two ways.

Laravel Clear cache using Artisan Command

We are going to clear Laravel cache using Artisan command

Reoptimized class loader

Clear Facade Value

Laravel Clear Route Cache

Laravel Clear View Cache

Laravel clear Config Cache

Finally, We are learning Laravel clear cache using artisan command. But how to clear Laravel cache when we are using shared hosting. Because Shared hosting doesn’t provide command line interface. So, Let’s see how we can clear Laravel cache on shared hosting.

Laravel Clear cache in shared hosting server

We are going to learn about Laravel clear cache in shared hosting server by Laravel Route using Artisan Command

Now, You just need to call route URL for clearing cache on shared hosting.

Today, We are going to learn how to use laravel by creating Laravel 5 Hello World Application step by step. In this, we are going through the basic of Laravel 5 Hello World application by creating Laravel Route, Controller, View.

Introduction

Laravel is a full-framework for all kind of application. Hence, Laravel is the most popular highest rating framework on Github. Laravel is easy to use, with a simple learning curve, and a minimum number of steps required to get an app or website up and running.

First of all, We are going to install Laravel by following this steps.

Laravel 5 Hello World Application

We are going to learn Laravel 5 Hello World Application step by step.

Route

A route is a URL pattern that is mapped to a handler. Laravel route directs an incoming request to function or controller. Also, a route is a store on the “routes” directory. Let’s create the route for Hello World Application.

Let’s Open “routes/web.php” file for creating the route.

Laravel allow us to call view file directly from the Route. Now, let’s create the route that calls view file from Controller.

Finally, The Route is ready for “Hello World” application Now, Let’s move for the Controller.

Controller

Instead of defining all of your logic in the route files,  You may wish to create Controller class for organizing the logic. Controllers can group related request handling logic into a single class. Controllers are store in the app/Http/Controllers directory.

Let’s create the “HelloworldController.php” File at the “app/Http/Controllers” Folder or else we can generate Controller file by following artisan command like

After, Creating the Controller let’s create the “HelloWorld” method like

Finally, We are ready with Controller. We just call view file using Controller class instead of the Route. Now, let’s we are going to create the view file.

View

View file contains the HTML served by your application and separate your controller/application logic from your presentation logic. Views are store in the resources/views directory.

Finally, We are ready for the Laravel 5 Hello World Application. Now, let’s run the application and see the output.

Run laravel application by the following command

Now, Running the Laravel 5 application by following URL “http://localhost:8000/hello-world”

Output get something like this.

LaravelHive – Laravel 5 Hello World!

Laravel is the most popular object-oriented PHP framework. Today, We are going to install Laravel on windows with XAMPP server.  For install Laravel on the windows system, We need to install XAMPP server on windows. Let’s install Laravel on windows system with XAMPP server step by step.

Install XAMPP

First of all, We are going to install XAMPP, If XAMPP server is not installed on your server then let’s first install XAMPP on your windows system. Let’s download the XAMPP server and install it on the windows system.

Also, Make sure when downloading the XAMPP version as compatible with Laravel version.

Install Composer

Laravel utilizes Composer to manage its dependencies. due to, We need to install Composer After, installation the XAMPP server on windows system, let’s download and install the composer before using Laravel.

Install Laravel on windows using composer

After, installing XAMPP server and Composer on the windows system. Now, we are going to installing Laravel on windows using composer. Just follow the command for installing Laravel using composer step by step.

After, install laravel application let’s follow the below command for running Laravel application

Finally, We are ready to use Laravel application using localhost:8000 URL.
How to install Laravel on windows with xampp server?

So, It’s too easy to installing Laravel application on windows server If you face any issue on Laravel installation writes the comment below. Also, Please let me know if you have any corrections or additions.