Events provides a simple observer implementation, allowing you to subscribe and listen for events in your application. In this posts you can learn how to create event for email send in your laravel 5.2 application. event is very help to create proper progmamming way. First create event using bellow command.
<pre class="prettyprint lang-php">php artisan make:event SendMail</pre>
Ok, now you can see file in this path <strong class="path">app/Events/SendMail.php</strong> and put bellow code in that file.
<pre class="prettyprint lang-php">
Laravel 5.3 release few days ago and they upgrade several feature on Laravel 5.3. They also some changes on directory structure and etc.
So, Today I am going to give you one example how to import and export xls, xlsx and csv files. I also added post for Laravel 5, but this example will help you to implement on your Laravel 5.3 application.
In this example through you can import excel or csv to store in database and export or download excel or csv file from database table. For this example i use maatwebsite package from scratch.
Maatwebsite package though we can easily working with csv and .....
Its very common need to get last insert id in programming field, if you are working on laravel framework and you want to fetch last created id, i mean max id, then you do easily.laravel provide method to get last inserted id.
If you are working with DB::table() then you have to use insertGetId() for insert data into database. this function always return inserted record id(primary key).it is very simple way to get id, in following example you can see and undestand more:
public function getLastInsertedIdDB()
$id = DB::table('items')->inser.....
In this post i want to share with you how to create Repository Pattern in Laravel 5 application. generally we are getting data directly from model, I mean we are use just MVC. But if you have big application then it is better way if you use Repository Pattern. I will give you few step to create Repository Pattern. normally we use directly from Model but if you make Repository Pattern for every module then it is good way to develop laravel application.
<img width="100%" style="border:2px solid red" src="/upload/Laravel-5-Repository-Pattern-Tutorial.png">
<strong class="step">Step 1: Create In.....
if you want to use ckeditor in laravel and you also want to add file uploading as well. if you are use simply in php then it is very simple. but if you are set laravel then you fetch many problem like i also fetch lots of problem.
Now, i will give you few step to set ckeditor with file uploading and you will easily apply this. this is a very simple to browse your image, file etc upload.
use ckeditor in php, use ckeditor in laravel 4, use ckeditor in laravel 5, how to add ckeditor in laravel, laravel ckeditor image upload, laravel ckeditor example, laravel ckeditor sample, ckeditor laravel 4,.....
In this post i want to show you how to use subquery with join in laravel query builder. Whenever you need to use subquery in your laravel project you can use following example and learn hot to use subquery. In bellow example you can see we add subquery using DB::raw(), DB::raw() throught we can select our subtable and after in second argument i added compare your field. That way you can easily fire subquery with laravel 5.2 query builder.
$data = DB::table("items")
Multiple authentication is very important in big application of laravel. If you work on large project then you mostly prefer to diferente tables, like you always prefer "users" table for site user registration and "admins" table for admin user that way make strong security. we always use Auth for making user authentication but you have question how to make admins with auth then you can do easily by following step.
<strong class="step">Step 1: Auth Config Setting</strong>
In this step we will add new admin guard from auth.php file of config directory. so first open auth.php file and add bellow.....
We always need to add validation on form like registration form, contact form, login form etc. we always prefer to give validation error after page refresh but you can give validation without page refresh. If you use bootstrap then you can use easily validator.js plugin.
validator.js plugin gives client side validation without page refresh. We can use simply. validator.js plugin we can add validation in our PHP project, or any framework like laravel framework, codeigniter framework, symphony framework etc.
In this example i give you how can you give validation for require field, email, minle.....
Custom Validation Rule is very usefull and interesting concept of laravel 5 because custom validation throught we can re-use validation and use it easily by just name as like laravel core validation(required,same,in etc.). So, In this post i am going to show you how to create custom validation rules in laravel 5.2. you can create very simple way and use too. you can create custom validation rules by few following step and you can see preview of example that give for add custom validation rule. In this example you are creating <strong class="path">is_odd_string</strong> custom validation rule.
Sometimes, we need to create file of our project directory and give to download that zip file to users. we are always prefer zip file because it is very safe and secure from virus. If you want to generate zip file and donwload that file in your laravel 5 application then you do it easily using chumper/zipper composer package. In this post i give you example to create zip file and donwload from scratch. So first we have to follow bellow step for install package.
First fire following command on your terminal.
<pre>composer require chumper/zipper</pre>