Posts

Showing posts from October, 2017

Laravel after login, redirect back to previous url

If you are working on laravel and you want to do like: How to redirect back to the previous URL, After login. after login user, you can redirect his previous page as he was before. you can do this, I would like to give you two example. the first example is using intended() and the second one is using session but I don't know more but I think intended() is not working properly in laravel 5 but you can try in laravel 4. but I am sure I gave you an example with the session that works well in both. So, you can try anyone and get your solution, 1. using intended() and 2. session. Example 1: public function loginPost() {     if ($this->auth->attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))){         return Redirect::intended();     }     return back(); } Example 2: public function login() {         Session::put('url.intended',URL::previous());         return

Mysql storedprocedure with pagination in laravel 5

You are working on laravel with MySQL database. you had created MySQL stored procedure for get data and you want to call procedure with pagination in laravel 5 then you can not directly make pagination as laravel document.If you are using directly MySQL stored Procedure in your controller, model or repository and you want to give pagination like this way :     $data = DB::select(DB::raw('CALL store("6pm")'))->paginate(5);   This way you found error in your Laravel 5 website. we can't give directly this way pagination because your procedure will get all the data from database. but we can give pagination this way :     $pageNumber = Input::get('pageNumber', 1);      $paginate = 2;             $data =  DB::select(DB::raw('CALL store("6pm")'));          $offSet = ($pageNumber * $paginate) - $paginate;      $itemsForCurrentPage = array_slice($data, $offSet, $paginate, true);      $data = new \Illuminate\Pagination\Le

How to check Object is empty or not in Jquery/JavaScript ?

you can check your JavaScript OR jQuery object is empty or not, because we need to check many place our jQuery object is empty, null or undefined etc., So usually, we can check using $.isEmptyObject() as i explained as under. how to check empty object in javascript, how to check empty object in jquery, jQuery.isEmptyObject() example, jquery check object is null, jquery check object is empty, jquery check object is empty or not, how to check json object is empty or not in jquery, check if json object is empty jquery if($.isEmptyObject(your_object)){    alert("This Object is empty!"); }else{   alert("This Object is not empty!"); } you can also check other way to your object is empty or not i also describe under. if (your_object && your_object instanceof Array && !your_object.length) {    console.log('This Object is empty!'); } else {    console.log('This Object is not empty!'); }

Laravel Vs Rails

Image
It is very confusing for developers to decide which framework is best for their projects and choosing which one to learn can be a real challenge facing newbies to modern frameworks. After working in three ( django, laravel and rails - otherwise known as ruby on rails) frameworks, I am comparing these great frameworks on the basic of their motto, ease of learning, performance, strength & weakness of libraries and templates, support, future scope, job chances, cost and maintenance. I am using both. Laravel is new PHP framework and Rails is been around many years. Laravel is using rails strategies to be like Rails. Rails has powerful community than Laravel because it's older than Laravel. Ruby is modern language and more object oriented than PHP. Object Oriented PHP was added only since PHP 5. Let's break this down. To compare both we need to first compare PHP against Ruby. PHP is made for web and it's a web language. However Ruby isn't web specific. PHP i

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 . So i added is_admin column in my users table if use have is_admin = 1 then it can access "admins" route. So first create IsAdminMiddleware middleware using bellow command: Create Middleware php artisan make:middleware IsAdminMiddleware Ok, now you can found IsAdminMiddleware.php in app/Http/Middleware directory and open IsAdminMiddleware.php file and put bellow code on that file. In this file i check first if user is not login then it will redirect home route and other if user have not is_admin = 1 then it w

Share Content on Whatsapp using jQuery

Image
Why Whatsapp Share need? WhatsApp is one of the most popular messaging apps in the world – Facebook bought WhatsApp for $19 billion. One-third of world’s population is using Whatsapp on their smartphones. So adding WhatsApp share button in your website will be helpful to share content with anyone anytime anywhere! CSS Code to Style the Whatsapp Share Button:  .w3_whatsapp_btn {     background-image: url('icon.png');     border: 1px solid rgba(0, 0, 0, 0.1);     display: inline-block !important;     position: relative;     font-family: Arial,sans-serif;     letter-spacing: .4px;     cursor: pointer;     font-weight: 400;     text-transform: none;     color: #fff;     border-radius: 2px;     background-color: #5cbe4a;     background-repeat: no-repeat;     line-height: 1.2;     text-decoration: none;     text-align: left; } .w3_whatsapp_btn_small {     font-size: 12px;     background-size: 16px;     background-pos

Bootstrap Datetimepicker With Example

In this example I give you how to add time picker in your PHP application or HTML etc. this is the full example if you just copy and past below code then you can find time picker. you no need to install anything. I use datetimepicker library for time picker that way you can also set datepicker too. bootstrap datetimepicker is a very popular library. So if you also want to build date and time picker both then also you can set you can see below example. I set format "HH:mm:ss" but you can also add your custom format like "HH:mm" etc as you want but try this.... and also you set up for 12 hr format by using "HH:mm  A". For More Details Click Hear <html lang = "en" > <head> <title> Bootstrap Timepicker Example </title> <link href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel = "stylesheet" > <script src = "http://ajax.googlea

Step by Step install xampp and laravel in windows

Image
 Laravel is a most popular framework for PHP. Laravel provides lots of functionality like data migration, MVC, blade template etc. But if you don't know how to install laravel in your windows system then you can run laravel easily by following few step. In this installation, we use xampp server for PHP. Step 1: Install Xampp In this step we have to install xampp for PHP, if you haven't install xampp server in your system then you can download and install from here : Download xampp make sure you have to download >5.5.9 PHP version because laravel 5 requires at least 5.5.9 version. Step 2: Install Composer After xampp server installs successfully, you have to install composer so you haven't install yet then you can download from here:  Download Composer . Step 3: Create Laravel Project After Composer installs successfully, we can run composer command in our system so now we can create new laravel application using below command. I listed three co

How to set Datepicker in bootstrap with DateFormat

You are working on bootstrap and you want to add datepicker, then you have to use bootstrap-datepicker library. but if you are new and how to add datepicker in bootstrap then I provide you an example of bootstrap datepicker. How to set Datepicker in bootstrap Datepicker, how to use datepicker in bootstrap, implement bootstrap datepicker, use bootstrap datepicker in PHP, how to use bootstrap datepicker in HTML. <title> How To Use Datepiker </title> <link href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel = "stylesheet" > <link href = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel = "stylesheet" > <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" ></script> <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js

How to set maxlength for textarea in javascript ?

Today, I was planning to post something like regarding javascript. I was thinking what post should I add and I plan to make maxlength validation with display remaining character count using javascript. So you can simply make character limit with remaining counter in javascript. Here, I am going to make a very simple example to do this, you don't require to import jquery. You have to just write following javascript code. So I used the onkeyup and the onkeydown event of code javascript. It would be easy to use using onkeydown and onkeyup event and make it character count validation in HTML. So let's just see below example and copy that code. You will get a fresh example. <!DOCTYPE html> <html> <head> <title> How to set maxlength for textarea in javascript? </title> </head> <body> <div class = "container" > <form> <textarea name = "message" placeholder = "Wri