What is Java

What is Java
Java is a programming language that is highly popular and has dominated the field from the early 2000s. James Gosling developed Java with Mike Sheridan and Patrick Naughton in 1995, and it is a class-based and object-oriented language, similar to C++, with advanced and simplified features.
Java has continued to be a popular language because of the constant updates and support that is still being offered for the language. The independent programming language follows the logic of “Write once; Run anywhere.” i.e. compiled Java code can run on all platforms which supports Java.
The maturity of Java lends it and its developers a lot of reliability as almost all of the kinks and errors have been experienced and worked through.

Java Features
Java has a lot of great features that make it a fantastic option for your applications and software.
Simple: Java has simplified the language by removing complexities such as pointers and operator overloading as seen in many other programming languages.

  • Portable: Java is platform-independent meaning any application written for one platform can easily be ported to another platform
  • Object-oriented: Everything in Java is an “object”. Objects can have multiple states, described by attributes and behaviours executed in functions. Interactions between these objects perform all of the program functionality.
  • Secured: Java is compiled into bytecode, which is not human readable. Java runs in isolation, within the JVM to prevent penetration from malicious sources. This dramatically hinders any tampering and is unlikely to be affected by viruses/malware
  • Dynamic: Memory management in Java is dynamic, and its approach reduces memory allocation errors as well as memory leaks. This allows for better overall performance and reliability of applications.
  • Distributed: Java exposes an interface called the Remote Method Invocation (RMI), this allows any application on a network to remotely execute a method and retrieve the results. On a larger scale, this means Java can be used to execute functions across the internet without compromising either system.
  • Robust: Reliability in Java applications is improved by error checking mechanisms that run both at compilation and execution time.
  • High Performance: Just-In-Time (JIT) compilation is an approach used by Java to increase performance by only converting its bytecode to native machine code as and when it’s required resulting in faster and lighter performance software.
  • Multithreaded: Most modern CPU’s support multithread execution, Java can leverage that technology to run different threads concurrently. Concurrent operations lead to reduced execution time and maximised usage of processing power.

Popular Java Applications around the World

Google and Andriod OS
Google uses Java for most of its products, and it is the main language that is used in their back-end of the Android Operating System

Netflix
Netflix uses Java for most of its applications back-end

Spotify
Spotify uses Java to implement some functionality of its web application. For example to log and stabilise data transfers

LinkedIn
Java is one of the main languages of LinkedIns’ server-side platform. It helps to implement the logging of functionality, messaging and recognise and convert links into text. LinkedIns’ Android App was also developed using Java

Uber
Uber used Java as the main language in the development of its mobile application.

Amazon
Uses Java for its web services (AWS). Amazon writes automation scripts in Java as it is well-supported, has many internal tools and environments available for developing helper tools.

Minecraft
Java is used in the popular game primarily for building game logic, rendering and messaging.

 

Java Applications
Java is an extremely versatile programming language that has millions of applications, and here we will look at how Java is used in a couple of business sectors to manage data, solve problems and give insights.

  • Banking – Java is used in Banking Applications for Transaction Management
  • Retail – Java is used in many restaurants and stores for their Billing Applications
  • Information Technology – Can be used to solve implementation and infrastructure dependencies
  • Android – All Android applications are either written in Java or use a Java API
  • Financial Services – Java is used in Financial Institutions in server-side applications
  • Stock Market – Java is used in writing algorithms to advise which company to invest in
  • Scientific and Research Community – Java is used to create applications to deal with huge amounts of data

Java is an amazing programming language that we love to know everything about. Whether you are a business who needs help with your in-house Java application, an aspiring programmer wanting to specialise in Java or a conglomerate needing to upskill their team, MaH Quests are the Java specialists you can rely on.

Java 8 Features : forEach method

Java 8 popular features:

Some of the important Java 8 features are;

  • forEach() method in Iterable interface
  • default and static methods in Interfaces
  • Functional Interfaces and Lambda Expressions
  • Java Stream API for Bulk Data Operations on Collections
  • Java Time API
  • Collection API improvements
  • Concurrency API improvements
  • Java IO improvements
  • Miscellaneous Core API improvements

 

Let’s have a brief look on these Java 8 features. I will provide some code snippets for better understanding, so if you want to run programs in Java 8, you will have to setup Java 8 environment by following steps.

forEach() method in Iterable interface

Whenever we need to traverse through a Collection, we need to create an Iterator whose whole purpose is to iterate over and then we have business logic in a loop for each of the elements in the Collection. We might get ConcurrentModificationException if iterator is not used properly.

Java 8 has introduced forEach method in java.lang.Iterable interface so that while writing code we focus on business logic only. forEach method takes java.util.function.Consumer object as argument, so it helps in having our business logic at a separate location that we can reuse. Let’s see forEach usage with simple example.

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import java.lang.Integer;
 
public class Java8ForEachExample {
 
     public static void main(String[] args) {
         
          //creating sample Collection
          List myList = new ArrayList();
          for(int i=0; i<10; i++) myList.add(i);
         
          //traversing using Iterator
          Iterator it = myList.iterator();
          while(it.hasNext()){
               Integer i = it.next();
               System.out.println("Iterator Value::"+i);
          }
         
          //traversing through forEach method of Iterable with anonymous class
          myList.forEach(new Consumer() {
 
               public void accept(Integer t) {
                     System.out.println("forEach anonymous class Value::"+t);
               }
 
          });
         
          //traversing with Consumer interface implementation
          MyConsumer action = new MyConsumer();
          myList.forEach(action);
         
     }
 
}
 
//Consumer implementation that can be reused
class MyConsumer implements Consumer{
 
     public void accept(Integer t) {
          System.out.println("Consumer impl Value::"+t);
     } 
}

The number of lines might increase but forEach method helps in having the logic for iteration and business logic at separate place resulting in higher separation of concern and cleaner code.

Overview

Introduced in Java 8, the forEach loop provides programmers with a new, concise and interesting way for iterating over a collection.

Basics of forEach
 

In Java, the Collection interface has Iterable as its super interface – and starting with Java 8 this interface has a new API:

void forEach(Consumer action)

Simply put, the Javadoc of forEach stats that it “performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.”

 

And so, with forEach, we can iterate over a collection and perform a given action on each element, like any other Iterator.

 

For instance, a for-loop version of iterating and printing a Collection of Strings:

 

for (String name : names) {
    System.out.println(name);
}

We can write this using forEach as:

names.forEach(name -> {     System.out.println(name); });

Using the forEach Method

We use forEach to iterate over a collection and perform a certain action on each element. The action to be performed is contained in a class that implements the Consumer interface and is passed to forEach as an argument.

 

The Consumer interface is a functional interface (an interface with a single abstract method). It accepts an input and returns no result.

 

Here’s the definition:

@FunctionalInterface
public interface Consumer {
    void accept(T t);
}
Therefore, any implementation, for instance, a consumer that simply prints a String:
Consumer printConsumer = new Consumer() {
public void accept(String name) {
System.out.println(name);
};
}; public void accept(String name) { System.out.println(name); }; };
can be passed to forEach as an argument:
names.forEach(printConsumer);

But that is not the only way of creating an action via a consumer and using forEach API.

 

Let’s see the 3 most popular ways in which we will use the forEach method:

 

3.1. Anonymous Consumer Implementation

 

We can instantiate an implementation of the Consumer interface using an anonymous class and then apply it as an argument to the forEach method:

 

Consumer printConsumer= new Consumer() {
public void accept(String name) {
System.out.println(name);
}
};
names.forEach(printConsumer); public void accept(String name) { System.out.println(name); } }; names.forEach(printConsumer);

WordPress Tutorials – Selecting Theme, customizing and adding plugins

Most beginners feel overwhelmed when it comes to selecting a theme for their WordPress site. There are thousands of free and paid options. Each theme looks better than the other. How do you choose the best theme for WordPress? Before going any further, lets look at the factors to consider when chosing a wordpress theme.

These factors include

  • Striving for simplicity
  • Responsive websiteBrowser Compitability
  • Supported Plugins
  • Transalation / Multilingual Ready
  • Page Builder
  • Support Options For When You Need Help
  • SEO Friendliness
  • Rating and Reviews

Lets start off by selecting them for a website

Theme Visual Appearance

The visual appearance of your WordPress site is controlled by a WordPress theme. WordPress themes are professionally designed templates that you can install on your website to change its appearance.

By default, each WordPress site comes with a basic theme. If you visit your website, then it will look something like this:

This is not very appealing for most users. But don’t worry, there are thousands of free and paid WordPress themes that you can install on your site.

Changing Theme In WordPress

You can change your theme from the WordPress admin dashboard. Visit Appearance » Themes page and then click on the ‘Add New’ button.

On the next screen, you will able to search from 4,492 free WordPress themes that are available in the official WordPress.org themes directory. You can sort them by popular, latest, featured, as well as other feature filters (i.e industry, layout, etc).

I will be using Bento. Bento is a popular multi-purpose free WordPress theme with flexible design options for all kind of websites. If you know the name of the free theme you want to install, then you can look for it by entering its name in the search field. WordPress will show you the theme in search results. You will need to take your mouse over to the theme and then click on the Install button.

Once you have installed your theme, you can customize it by clicking on the Customize link under the Appearance menu. This will launch the theme customizer where you will be able to change your theme settings with live preview of your website.

You don’t need to finalize all theme settings right away. You will be able to customize it much better once you have some content on your website. Let’s see how to add content to your WordPress site.

Adding Content To Your Website

WordPress comes with two default content types called posts and pages. Posts are part of a blog and appear in reverse-chronological order (newer items displayed first). On the other hand, pages are meant to be static “one-off” type content such as your about page, contact page, privacy policy, etc. By default, WordPress shows your blog posts on the front page of your website. You can change that, and make WordPress show any page as the front-page of your website (I will show you how to do that later in this guide). You can create a separate page for your blog or news section. In fact, you can create a website without any blog section at all.

Having said that, let’s add some content to your website. You’ll start by adding a few pages to your WordPress site. Don’t worry if you don’t have enough content for these pages at the moment. You can always edit and update them.

Head over to Pages » Add New page in WordPress admin area. This will bring you to the page editor screen, which looks like this:

First you need to provide a title for your page, let’s call this page ‘Home’. After that you can add content in the text editor below. You can add text, links, images, embed videos, audio, etc.

After adding content to your page, you can click on the publish button to make it live on your website. You can repeat the process by adding more pages for different sections of your website. For example, an about page, contact us, and a blog page to display blog posts.

Now let’s add a few blog posts as well.

Head over to Posts » Add New in your WordPress admin area.

What Happens when You Add A New Post?

You will see a screen much like you saw earlier when adding
pages.

You can add a post title and then add content in the visual post
editor. You’ll also notice some extra options like post formats, categories and tags.

You can click on the save button to store your post as a draft or click on the publish button to make it visible on your site.

Customizing And Improving Your Website

Now that you have created some content on your website, you will be able to customize and put it all in a nice presentable shape on your website. Let’s start by setting up a static front Page.

Setting Up A Static Front Page

You need to visit the Settings » Reading page in your WordPress admin area. Under the ‘Front page displays’ option click on the static front page and then select ‘Pages’ you created earlier for your home and blog pages.

Don’t forget to click on the ‘Save Changes’ button at the bottom of the page to store your changes. WordPress will now use the page titled ‘Home’ as your site’s front page and ‘Blog’ page to display your blog posts.

Change Site Tittle And Tagline

During the installation you get to choose your site’s title. WordPress automatically adds a tag line to your site title that says ‘Just another WordPress site’. You can change both your site’s title and tagline at any time by visiting Settings » General page.

Your site title will be the name of your website like WPBeginner. The tag line is usually a single line that describes your website. You can also leave the tag line field blank if you want. Don’t forget to click on the save changes button to store your settings.

Set Up Commets Settings

WordPress comes with a built-in comment system allowing your users to leave comments on your posts. This is great for user engagement, but it is targeted by spammers as well. To deal with this, you’ll need to enable comment moderation on your website. Visit Settings » Discussions page and scroll down to ‘Before a comment appears’ section. Check the box next to ‘Comment must be manually approved’ option

Don’t forget to click on the save changes button to store your settings.

Creating Navigation Menus

Navigation menus allow your users to browse different pages or sections on your website. WordPress comes with a powerful navigation menu system, and your WordPress theme utilizes this system to display menus.

Let’s add a navigation menu to your website.First, you need to visit Appearance » Menus page. Enter a name for your navigation menu and click on the create menu button.

WordPress will now create your navigation menu. But it will be empty at the moment. Next, you need to select the pages you want to display in your menu and then click on add to menu button.

You will notice your selected pages filling the empty area of your navigation menu. You can move them up and down to rearrange their position in the menu.

Now you need to select a display location. These locations are
defined by your WordPress theme. Usually, most WordPress themes have a primary
menu that appears on top.

Finally, click on the save menu button to store your navigation menu. You can now visit your website to see the menu in action.

Installing Plugins

WordPress site. Think contact form, photo galleries, etc.

There are currently more than 49,000 free plugins available for WordPress. There are also paid plugins sold by third-party websites and developers. With this many plugins, how do you find which plugins to install? Here is our list of essential plugins that you should install on your site right away. All of them are free.

Features

Website Optimization

Security

  • Updraft Plus –
    Create automatic scheduled backups of your website
  • Sucuri –
    Website security audit and malware scanner
 
 

Thats it for today. i hope this information was helpful.

Laravel File Storage

Helllo once again, im back with an awesome topic. Today we going to be discussing File Storage

Introduction

Laravel provides a powerful filesystem abstraction thanks to the wonderful Flysystem PHP package by Frank de Jonge. The Laravel Flysystem integration provides simple to use drivers for working with local filesystems and Amazon S3. Even better, it’s amazingly simple to switch between these storage options as the API remains the same for each system.

Configuration

The filesystem configuration file is located at config/filesystems.php. Within this file you may configure all of your “disks”. Each disk represents a particular storage driver and storage location. Example configurations for each supported driver are included in the configuration file. So, modify the configuration to reflect your storage preferences and credentials.

You may configure as many disks as you like, and may even have multiple disks that use the same driver.

The Public Disk

The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.

To create the symbolic link, you may use the storage:link Artisan command:

Once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset helper:

echo asset('storage/file.txt');

The Local Driver

When using the local driver, all file operations are relative to the root directory defined in your filesystems configuration file. By default, this value is set to the storage/app directory. Therefore, the following method would store a file in storage/app/file.txt:

Storage::disk('local')->put('file.txt', 'Contents');

Permissions

The public visibility translates to 0755 for directories and 0644 for files. You can modify the permissions mappings in your filesystems configuration file:

'local' => [
    'driver' => 'local',
    'root' => storage_path('app'),
    'permissions' => [
        'file' => [
            'public' => 0664,
            'private' => 0600,
        ],
        'dir' => [
            'public' => 0775,
            'private' => 0700,
        ],
    ],
],

Retrieving Files

The get method may be used to retrieve the contents of a file. The raw string contents of the file will be returned by the method. Remember, all file paths should be specified relative to the “root” location configured for the disk:

$contents = Storage::get('file.jpg');

The exists method may be used to determine if a file exists on the disk:

$exists = Storage::disk('s3')->exists('file.jpg');

The missing method may be used to determine if a file is missing from the disk:

$missing = Storage::disk('s3')->missing('file.jpg');

Downloading Files

The download method may be used to generate a response that forces the user’s browser to download the file at the given path. The download method accepts a file name as the second argument to the method, which will determine the file name that is seen by the user downloading the file. Finally, you may pass an array of HTTP headers as the third argument to the method:

return Storage::download('file.jpg');

return Storage::download('file.jpg', $name, $headers);

File URLs

You may use the url method to get the URL for the given file. If you are using the local driver, this will typically just prepend /storage to the given path and return a relative URL to the file. If you are using the s3 driver, the fully qualified remote URL will be returned:

use Illuminate\Support\Facades\Storage;

$url = Storage::url('file.jpg');

Storing Files

The put method may be used to store raw file contents on a disk. You may also pass a PHP resource to the put method, which will use Flysystem’s underlying stream support. Remember, all file paths should be specified relative to the “root” location configured for the disk:

use Illuminate\Support\Facades\Storage;

Storage::put('file.jpg', $contents);

Storage::put('file.jpg', $resource);

File Uploads

In web applications, one of the most common use-cases for storing files is storing user uploaded files such as profile pictures, photos, and documents. Laravel makes it very easy to store uploaded files using the store method on an uploaded file instance. Call the store method with the path at which you wish to store the uploaded file:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class UserAvatarController extends Controller
{
    /**
     * Update the avatar for the user.
     *
     * @param  Request  $request
     * @return Response
     */
    public function update(Request $request)
    {
        $path = $request->file('avatar')->store('avatars');

        return $path;
    }
}

There are a few important things to note about this example. Note that we only specified a directory name, not a file name. By default, the store method will generate a unique ID to serve as the file name. The file’s extension will be determined by examining the file’s MIME type. The path to the file will be returned by the store method so you can store the path, including the generated file name, in your database.

You may also call the putFile method on the Storage facade to perform the same file manipulation as the example above:

$path = Storage::putFile('avatars', $request->file('avatar'));

Specifying A File Name

If you would not like a file name to be automatically assigned to your stored file, you may use the storeAs method, which receives the path, the file name, and the (optional) disk as its arguments:

$path = $request->file('avatar')->storeAs(
    'avatars', $request->user()->id
);

You may also use the putFileAs method on the Storage facade, which will perform the same file manipulation as the example above:

$path = Storage::putFileAs(
    'avatars', $request->file('avatar'), $request->user()->id
);

 


Deleting Files

The delete method accepts a single filename or an array of files to remove from the disk:

use Illuminate\Support\Facades\Storage;

Storage::delete('file.jpg');

Storage::delete(['file.jpg', 'file2.jpg'])

WordPress Tutorials 2019

What Is WordPress?

WordPress is an online, open source website creation tool
written in PHP. It is probably the easiest and most powerful blogging and
website content management system (or CMS) in existence today. Many couple of
years ago, WordPress was essentially used as a tool for creating blogs, it wasn’t
really focused on websites development, as years passed by things began to
change and now WordPress is well known for developing and creating amazing
websites for different organizations, thanks to changes to the core code, as
well as WordPress’ massive ecosystem of plugins and themes, you can create any type of website with
WordPress
.

For example, not only does WordPress power a huge number of
business sites and blogs, it’s also the most popular way to create an
eCommerce store. Also, you can create for the following:

  • Business websites
  • eCommerce stores
  • Blogs
  • Portfolios
  • Resumes
  • Forums
  • Social networks
  • Membership sites
    and pretty much anything else you can dream up.

Overview

For
anyone who wants to create website using WordPress, carefully follow the
following step by step guide on how to make a website.

An
overview from start to finish of all the essential steps to follow.

  • How to find and register a domain name for free
  • Choosing the best web hosting
  • How to install WordPress
  • Installing a template to change your site’s design
  • Creating pages in WordPress
  • Customizing WordPress with addons and extensions
  • Taking it further, building websites with more features

Resources to learn WordPress and get
support

For now, we will focus on the first 3 step and continue with the remaining on our next blog.

How To Find And Register A Domain Name For Free

One of the most common mistakes that beginners make is choosing
the wrong website platform. Thankfully, you are here so you will not be making
that mistake.

For most users, a self-hosted WordPress.org site is the
perfect solution. It comes with thousands of designs and addons which allow you
to create any kind of website you can think of.

WordPress is free for anyone to download and use to build any kind
of website without any restrictions.

If WordPress is free, then where is the cost coming from?

WordPress is free because you’ll have to arrange your own domain
name and hosting, which costs money.  A domain name is your website’s address on
the internet. This is what your users will type in their browsers to reach your
site (For example, wpbeginner.com or google.com).

Next, you’ll need website hosting. All websites on the internet
need hosting. This will be your website’s home on the internet. A domain name
typically costs $14.99/year and hosting costs start from $7.99/month. This is A
LOT for most people who are just starting out.

Bluehost hosting company

There are hosting companies like Bluehost, that has agreed to offer users a free domain name and over 60% off on web hosting. Bluehost is one of the largest hosting companies in the world. They are also an official WordPress recommended hosting partner.

Purchasing a domain name and hosting Via Bluehost Website requires you to go to the Bluehost website in a new browser window and click on the green ‘Get Started Now’ button.

This will bring you to a pricing page where you will need to choose a pricing plan for your website. Basic and plus plans are the most popular choices among our users.

You’ll need to click on select to choose the plan that you like and continue to the next step. On the next screen, you’ll be asked to select a new domain name.

You should basically stick to a .com domain name. Make sure that it is related to your business, easy to pronounce and spell, and easy to remember.

Choosing The Best Domain Name

Choosing an appropriate domain name for your business will require
you to use essential tools and follow the some basic tips. This link will help
in choosing the appropriate domain name for your business: https://www.wpbeginner.com/beginners-guide/tips-and-tools-to-pick-the-best-domain-for-your-blog/

After choosing your domain name, click on the next button to continue. Now you’ll be asked to provide your account information such as name, address, email, etc. On this screen, you will also see optional extras that you can purchase. We generally don’t recommend purchasing these extras. You can always add them later on, if you decide that you need them.

Next, you will add your payment information to finish the purchase. After completing your purchase, you’ll receive an email with details on how to login to your web hosting control panel (cPanel). This is your hosting dashboard where you manage everything like getting support, setting up emails, etc. Most importantly, this is where you’ll install WordPress.

Installing WordPress

You will find tons of icons to do different things on your hosting account dashboard (cPanel). You’ll never need to use 95% of them, so you can safely ignore them. Scroll down to the website section in cPanel and then click on the WordPress icon.

You will now see Bluehost Marketplace Quick Install screen for WordPress. Click on the ‘Get Started’ button to continue. On the next screen, you will be asked to select the domain name where you want to install WordPress. Choose your domain from the dropdown field and then click Next.

Now you’ll need to enter your website name, admin
username, and a password for your website. Don’t worry, you can change them
later in WordPress settings if you need to.

You’ll also need to check all the checkboxes on the screen and then click on the ‘Install’ button to continue.

Quick Install will now start installing WordPress on your website. Meanwhile, it will show you some website templates that you can install on your site. You don’t need to do that right now because we’ll show you how to find and install free WordPress template on your website later in this guide. Once the installation is over, you’ll see a success message in the top header.

Now you need to click on the ‘Installation Complete’ link, and it will take you to the screen with your WordPress login URL and password.

Congratulations! You have created your first
WordPress website.

You can now head over to the WordPress login page.
Your login URL will look like this:

http://www.yourdomain.com/wp-admin

You can login to your WordPress site using the admin username and password you entered earlier.

That was easy, Wasn’t it?

Now we will move on to the next step and choose a
design for your website on our next blog.

FORMS – HTML

HTML Forms are used to send data across the web and are often used as contact form to convertinformation input by a user into Leads.HTML forms are used to pass data to the server.
The common elements used in HTML form are form taginputtextarea,select, and label.

HTML Form Elements

HTML Form Tag

Form Tag defines the form and
within this tag, there is action attribute which tells the
form where its contents will be sent when it is submitted.

An HTML form can contain input
elements
checkboxradio buttonssubmit
button
 and more. A form can also contain select listtextareafieldsetlegend,
and label elements.

Create HTML Form

form is build inside </form> tag. See the
code below

<form action=“” method=“get” name=“enquiry”>


    /*Content*/


</form>


Form Attributes

HTML Form Attributes

Attribute

Values

Use

method

get or
post

http
get method submit form data but is visible in url.
post includes data in body. more secure as data is not visible to user in url

action

path

the
backend file collecting form data

name

any
name

name of
form control

 

Input Tag

The most important form element is the input element. The input element is used to get user information. An input element can be of type textpasswordcheckboxradio buttonsubmit button and more.

Attributes in Input element

Attribute Name

values

Use

type

text, password, file, radio, checkbox, button, submit, and reset

type defines type of input control.

size

default value is 20

change size of input control

tabindex

any numeric value

used to define a sequence followed by user when he navigate using Tab key

value

any possible value

set a default value of input control

maxlength

n digits

set maximum characters length

disabled

“”

disabled input control, or fieldset tag

checked

“”

choose checkbox and radio button

 

Input type text with label

 

Label is used to write the content just before text field. To Specify particular label, the value of for attribute inside label should match the id of input control..

Label with input

Top of Form

First Name: 

Bottom of Form

 

<label>First Name: <input type=”text”></label>

 

Label Outside Input

Top of Form

Last Name: Bottom of Form

 

<label for=”lname”>Last Name:</label>

<input type=”text” id=”lname”>

 Input Type Text with value

value attribute can also be used inside input or textarea. Usually we ask user to fill values, but if value is fixed, use value attribute.

Top of Form

First Name: 
Last Name: 

Bottom of Form

 

<form>

    <label for=”fname”>First Name:</label>

    <input type=”text” value=”First Name” id=”fname” >

 

    <label for=”lname”>Last Name:</label>

    <input type=”text” value=”Last Name” id=”lname” >

</form>


Maxlength



maxlength attribute is used to restrict no of characters in a text field. maxlength value is a number. Maxlength attribute is usefull for form validations.

Input with maxlength

Top of Form

First Name: 
Age: 

Bottom of Form

 

<form>

<label for=”fname”>First Name:</label>

<input type=”text” id=”fname” maxlength=”10″>

 

<label for=”age”>Age:</label>

<input type=”text” id=”age” maxlength=”3″>

</form>

 


 

Input Type Password

The input type password is used to write passwords. The password value is written in encrypt form. i.e. a user cannot see, copy or cut password data from input type password.

Top of Form

Password: 

Bottom of Form

 

<form>

    <label for=”pwd”>Password:</label>

    <input type=”password” id=”pwd” >

</form>

 


Input type File

Input type file let user to choose file from his system. This can be used to uplaod a picture, upload resume, upload a video or audio etc.

Default value of input type file is “No file choosen”. Once the file is uploaded, the file name replace this text followed by extension.

Top of Form

Resume: 

Bottom of Form

 

<form>

    <label for=”resume”>Resume:</label>

    <input type=”file” id=”resume”>

</form>

 

Radio Button

Radio Buttons are used to choose a single element among a group.
To allow window to choose a single radio, use name attribute with same value on both radio inputs.

Radio Button For Gender Selection

 Male  Female


 

    <input type=”radio” name=”gender” id=”male”>

    <label for=”m”>Male</label>

   

    <input type=”radio” name=”gender” id=”female”>

    <label for=”f”>Female</label>

Radio Button For Multiple Questions

Question 1

 Answer 1  Answer 2  Answer 3  Answer 4


Question 2

 Answer 1  Answer 2  Answer 3  Answer 4

 

 

Check Box

Checkbox are used to select multiple selections unlike radio button. They can be checked and unchecked. We can use checkboxs for hobbies, interestes, terms & conditions, etc.

HTML Checkbox

 
 

 
<label> <input type="checkbox"> :Bike</label>
<label> <input type="checkbox"> :Car</label>

Checkbox with disabled

Checbox can also have disabled attribute. A disabled checbox can’t be checked, means checked will remain checked, and unchecked will remain unchecked. See example

HTML Checkbox with disable

 
    <<input type="checkbox" disabled>>

Checkbox with checked

Default checbox state is unchecked. But we can change default state to checked by using checked attribute in input type checkbox. See example

HTML Checkbox with checked


 
<label><input type="checkbox" checked>: I Agree</label> 
<label><input type="checkbox" disabled checked>: I Agree </label>

 

 

Select Dropdown

select or select dropdown is used to fetch single or multiple options in dropdown list. Select options are fixed, thus used can choose only given option or options. To select city, country, date, month, year etc, Select Dropdown is used.

Select dropdown example

Current City:                                                                                                                                                                   –Select City– New York Chicago Los Angeles Washington DC

 

    <select>

        <option selected disabled<–Select City–</option>

        <option<New York</option>

        <option<Chicago</option>

        <option<Los Angeles</option>

        <option<Washington DC</option>

    </select>


Select with Optgroup

Optgroup element is used to group multiple options in select dropdown. The name of optgroup is set using label attribute in optgroup.

Current City:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               –Select City– New Delhi Kolkata Mumbai Chennai Noida Gurgram Faridabad Gaziabad

 

<select>

    <option selected disabled>–Select City–</option>

    <optgroup label=”Metros”>

        <option>New Delhi</option>

        <option>Kolkata</option>

        <option>Mumbai</option>

        <option>Chennai</option>

    </optgroup>

    <optgroup label=”Others”>

        <option>Noida</option>

        <option>Gurgram</option>

        <option>Faridabad</option>

        <option>Gaziabad</option>

    </optgroup>                           

</select>


Multiple Attribute

Multiple attribute is used in select dropdown to select more than one options by using Ctrl or Cmd key.

Choose Multiple Cities:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               –Select City– New Delhi Kolkata Mumbai Chennai Noida Gurgram Faridabad Gaziabad  Press Ctrl or Cmd for multi selections.

 

<select multiple>

    <option selected disabled>–Select City–</option>

    <optgroup label=”Metros”>

        <option>New Delhi</option>

        <option>Kolkata</option>

        <option>Mumbai</option>

        <option>Chennai</option>

    </optgroup>

    <optgroup label=”Others”>

        <option>Noida</option>

        <option>Gurgram</option>

        <option>Faridabad</option>

        <option>Gaziabad</option>

    </optgroup>                           

</select>

 


Choose Date Of Birth using Select Dropdown

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              –Choose Month– JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               –Choose Date– 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

 

 

Textarea

Textarea is used to write multiple line. Like post, query, address, comments, reviews etc. Textarea can have row and col attributes. Default rows are 2, and default columnns are 20.

Textarea Example








 

    <textarea></textarea>

   

    <textarea rows=”4″></textarea>

   

    <textarea rows=”4″ cols=”30″></textarea>

 

 

Button

Submit Button

Submit Button or input type submit is used to send information from user to web server. Submit button can be used only once in a form tag.

Submit Button example

 
    <input type="submit">

Reset Button

Reset Button or input type reset is used to reload form data, without refreshing webpage. Reset is also used once in a form tag.

Create reset Button

 

 
    <input type="reset">

Button Tag

Button Tag or Button can alose create buttons, like input type button. Button Tag is pair element. We can use image, icon or child element inside button tag.

Type of buttons

·         Button,   <button>Button</button>.

·         Reset button,   <button type="reset">Button</button>.

·         Submit button,   <button type="submit">Button</button>.

Button Tag Example

   

 

 



 
    <button>Button</button>

 

 

Field Set

Form or form controls can also be placed inside fieldset tagFieldset tag is used to group form or multiple input controls. Fieldset group form controls in bordered area. We can also use legend tag inside fieldset.

The main functionality of Fieldset is to disable multiple form controls.

Fieldset with Legend

Enquiry Form

Top of Form

Name:   

Bottom of Form



 

<fieldset>

    <legend>Enquiry Form</legend>

        <form onsubmit=”return false”>

            <label>Name:<input type=”text”></label>

            <input type=”submit”>

            <input type=”reset”> </form>

</fieldset>   


Fieldset with disabled

Fieldset also supports disabled attribute. By adding disables attribute, all form controls including submit button are disabled. Thus user cannot fill and submit form data.

Enquiry Form

Top of Form

Name:   

Bottom of Form



 

<fieldset disabled>

    <legend>Enquiry Form</legend>

        <form onsubmit=”return false”>

            <label>Name:<input type=”text”></label>

            <input type=”submit”>

            <input type=”reset”> </form>

</fieldset>

 

Contact Form Example

A complete HTML Form with all inputs, select dropdown, radio buttons, checkbox, textarea, submit and reset buttons.

Top of Form

Name

 

Email

 Check

Age

 

Country

 

Password

 

Resume

 

Hobbies

 Cricket  Football

Gender

 Female  Male

City

–Choose City–
New Delhi
Mumbai
Channai
Kolkata
Noida
Gurgram
Faridabad
Gaziabad

Address

 

 

 

Bottom of Form

 

<form>

    <table>

        <tr>

            <td>

                <label for=”uname”>Name</label>

            </td>

            <td>

                <input type=”text” id=”uname” name=”username”>

            </td>

        </tr>

        <tr>

            <td>

                <label for=”uemail”>Email</label>

            </td>

            <td>

                <input type=”text” id=”uemail” name=”usermail”>

                <button type=”button”>Check</button>

            </td>

        </tr>

        <tr>

            <td>

                <label for=”age”>Age</label>

            </td>

            <td>

                <input type=”text” name=”userage” id=”age” size=”2″ maxlength=”2″>

            </td>

        </tr>

        <tr>

            <td>

                <label>Country</label>

            </td>

            <td>

                <input type=”text” value=”India” name=”country” disabled>

            </td>

        </tr>

        <tr>

            <td>

                    <label for=”pass”>Password</label>

            </td>

            <td>

                    <input type=”password” id=”pass”>

            </td>

        </tr>

        <tr>

            <td>

                <label for=”res”>Resume</label>

            </td>

            <td>

                <input type=”file” id=”res”>

            </td>

        </tr>

        <tr>

            <td>

                <label>Hobbies</label>

            </td>

            <td>

                <label>

                    <input type=”checkbox” checked> Cricket

                </label>

                <label>

                    <input type=”checkbox”> Football

                </label>

            </td>

        </tr>

        <tr>

            <td>

                <label>Gender</label>

            </td>

            <td>

                <label>

                    <input type=”radio” value=”f” name=”gender”> Female</label>

                    <label>

                    <input value=”m” type=”radio” name=”gender”> Male</label>

            </td>

        </tr>

        <tr>

            <td>

                    <label for=”city”>City</label>

            </td>

            <td>

                    <select id=”city” name=”city”>

                        <option disabled selected>–Choose City–</option>

                            <optgroup label=”Metros”>

                                <option>New Delhi</option>

                                <option>Mumbai</option>

                                <option>Channai</option>

                                <option>Kolkata</option>

                            </optgroup>

                            <optgroup label=”Others”>

                                <option>Noida</option>

                                <option>Gurgram</option>

                                <option>Faridabad</option>

                                <option>Gaziabad</option>

                            </optgroup>

                    </select>

            </td>

        </tr>

        <tr>

            <td>

                <label>Address</label>

            </td>

            <td>

                <textarea rows=”4″ cols=”40″></textarea>

            </td>

        </tr>

        <tr>

            <td></td>

            <td>

                <input type=”submit” value=”Submit”>

                <input type=”reset”>

            </td>

        </tr>

    </table>

</form>

 

Inside form element, button will work as submit button, but outside form, button will work as button.

 

 

the results does not apper well on the blog, if you follow the code well you will get the appropriate results.

Carefully follow the video bellow to get clearity and to start on the right track.

Bootstrap Tables And List Group

Bootstrap Tables

You can add styling to your tables using bootstrap.. lets look at different style classess offered by bootstrap.

You can style your tables in bootstrap based on the lists below:

  • Bootstrap Basic Table
  • Striped Rows
  • Bordered Table
  • Hover Rows
  • Condensed Table
  • Contextual Classes
  • Responsive Tables

Bootstrap Basic Table

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>
<div class=“container”>
  <h2>Basic Table</h2>
  <p>The .table class adds basic styling (light padding and only horizontal dividers) to a table:</p>            
  <table class=“table”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>
</body>
</html>

RESULTS:

STRIPPED ROW

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
 
<body>
<div class=“container”>
  <h2>Striped Rows</h2>
  <p>The .table-striped class adds zebra-stripes to a table:</p>            
  <table class=“table table-striped”>
    <thead>
      <tr>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Email</th>
    </tr>
    </thead>
   <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
<tr>
     <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
    </tbody>
  </table>
</div>
</body>
</html>

Results:

Bordered Table

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=“container”>
  <h2>Bordered Table</h2>
  <p>The .table-bordered class adds borders to a table:</p>            
  <table class=“table table-bordered”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>

Hover Table

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=“container”>
  <h2>Hover Rows</h2>
  <p>The .table-hover class enables a hover state on table rows:</p>            
  <table class=“table table-hover”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>

Results

Notice that when you over over the table rows, the colour of the row changes from white to Gray. This is affected by <table class=“table table-hover”> ,a bootstrap class . There are many different classess to look at for different tables in bootstrap.

Condensed Table

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=“container”>
  <h2>Condensed Table</h2>
  <p>The .table-condensed class makes a table more compact by cutting cell padding in half:</p>            
  <table class=“table table-condensed”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>

Results:

Contextual Classes

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=“container”>
  <h2>Contextual Classes</h2>
  <p>Contextual classes can be used to color table rows or table cells. The classes that can be used are: .active, .success, .info, .warning, and .danger.</p>
  <table class=“table”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Default</td>
        <td>Defaultson</td>
        <td>def@somemail.com</td>
      </tr>      
      <tr class=“success”>
        <td>Success</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr class=“danger”>
        <td>Danger</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr class=“info”>
        <td>Info</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
      <tr class=“warning”>
        <td>Warning</td>
        <td>Refs</td>
        <td>bo@example.com</td>
      </tr>
      <tr class=“active”>
        <td>Active</td>
        <td>Activeson</td>
        <td>act@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>


Results

Responsive Table

<!DOCTYPE html>
<html lang=“en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=“utf-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
  <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=“container”>
  <h2>Contextual Classes</h2>
  <p>Contextual classes can be used to color table rows or table cells. The classes that can be used are: .active, .success, .info, .warning, and .danger.</p>
  <table class=“table”>
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Default</td>
        <td>Defaultson</td>
        <td>def@somemail.com</td>
      </tr>      
      <tr class=“success”>
        <td>Success</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr class=“danger”>
        <td>Danger</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr class=“info”>
        <td>Info</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
      <tr class=“warning”>
        <td>Warning</td>
        <td>Refs</td>
        <td>bo@example.com</td>
      </tr>
      <tr class=“active”>
        <td>Active</td>
        <td>Activeson</td>
        <td>act@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>


Results

Bootstrap List Groups

Basic List Groups (Unordered List With Items)

To create a basic list group, use an <ul> element with class .list-group, and <li> elements with class .list-group-item:

Example

<ul class=”list-group”>
  
<li class=”list-group-item”>First item</li>
  
<li class=”list-group-item”>Second item</li>
  
<li class=”list-group-item”>Third item</li>
</ul>

 

List Group With Badges

To create a badge, create a <span> element with class .badge inside the list item:

Example

<ul class=”list-group”>
  
<li class=”list-group-item”>New <span class=”badge”>12</span></li>
  
<li class=”list-group-item”>Deleted <span class=”badge”>5</span></li>
  
<li class=”list-group-item”>Warnings <span class=”badge”>3</span></li>
</ul>

List Group With Linked Items

To create a list group with linked items, use <div> instead of <ul> and <a> instead of <li>:

Example

<div class=”list-group”>
  
<a href=”#” class=”list-group-item”>First item</a>
  
<a href=”#” class=”list-group-item”>Second item</a>
  
<a href=”#” class=”list-group-item”>Third item</a>
</div>

Active State

Example

Use the .active class to highlight the current item:

<a href=”#” class=”list-group-item active”>First item</a>

 

Example

To disable an item, add the .disabled class:

<a href=”#” class=”list-group-item disabled”>First item</a>

Contextual Classes

The classes for coloring list-items are: .list-group-item-successlist-group-item-infolist-group-item-warning, and .list-group-item-danger:

Contextual classes can be used to color list items:

<h2>List Group With Contextual Classes</h2>
  
    <ul class=“list-group”>
  
      <li class=“list-group-item list-group-item-success”>First item</li>
  
      <li class=“list-group-item list-group-item-info”>Second item</li>
  
      <li class=“list-group-item list-group-item-warning”>Third item</li>
  
      <li class=“list-group-item list-group-item-danger”>Fourth item</li>
  
    </ul>

Laravel Authentication

Introduction

Laravel makes implementing authentication very simple. In fact, almost everything is configured for you out of the box. The authentication configuration file is located at config/auth.php, which contains several well documented options for tweaking the behavior of the authentication services.

At its core, Laravel’s authentication facilities are made up of “guards” and “providers”. Guards define how users are authenticated for each request. For example, Laravel ships with a session guard which maintains state using session storage and cookies.

Providers define how users are retrieved from your persistent storage. Laravel ships with support for retrieving users using Eloquent and the database query builder. However, you are free to define additional providers as needed for your application.

Don’t worry if this all sounds confusing now! Many applications will never need to modify the default authentication configuration.

Database Considerations

By default, Laravel includes an App\User Eloquent model in your app directory. This model may be used with the default Eloquent authentication driver. If your application is not using Eloquent, you may use the database authentication driver which uses the Laravel query builder.

When building the database schema for the App\User model, make sure the password column is at least 60 characters in length. Maintaining the default string column length of 255 characters would be a good choice.

Also, you should verify that your users (or equivalent) table contains a nullable, string remember_token column of 100 characters. This column will be used to store a token for users that select the “remember me” option when logging into your application.

Authentication Quickstart

Laravel ships with several pre-built authentication controllers, which are located in the App\Http\Controllers\Auth namespace. The RegisterController handles new user registration, the LoginController handles authentication, the ForgotPasswordController handles e-mailing links for resetting passwords, and the ResetPasswordController contains the logic to reset passwords. Each of these controllers uses a trait to include their necessary methods. For many applications, you will not need to modify these controllers at all.

Routing

Laravel’s laravel/ui package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:

This command should be used on fresh applications and will install a layout view, registration and login views, as well as routes for all authentication end-points. A HomeController will also be generated to handle post-login requests to your application’s dashboard.

Views

As mentioned in the previous section, the laravel/ui package’s php artisan ui vue --auth command will create all of the views you need for authentication and place them in the resources/views/auth directory.

 

The ui command will also create a resources/views/layouts directory containing a base layout for your application. All of these views use the Bootstrap CSS framework, but you are free to customize them however you wish.

Authenticating

Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may access your application in a browser since the authentication controllers already contain the logic (via their traits) to authenticate existing users and store new users in the database.

Path Customization

When a user is successfully authenticated, they will be redirected to the /home URI. You can customize the post-authentication redirect location by defining a redirectTo property on the LoginControllerRegisterControllerResetPasswordController, and VerificationController:

Next, you should modify the RedirectIfAuthenticated middleware’s handle method to use your new URI when redirecting the user.

If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property:

Username Customization

By default, Laravel uses the email field for authentication. If you would like to customize this, you may define a username method on your LoginController:

Guard Customization

You may also customize the “guard” that is used to authenticate and register users. To get started, define a guard method on your LoginControllerRegisterController, and ResetPasswordController. The method should return a guard instance:

Validation / Storage Customization

To modify the form fields that are required when a new user registers with your application, or to customize how new users are stored into your database, you may modify the RegisterController class. This class is responsible for validating and creating new users of your application.

The validator method of the RegisterController contains the validation rules for new users of the application. You are free to modify this method as you wish.

The create method of the RegisterController is responsible for creating new App\User records in your database using the Eloquent ORM. You are free to modify this method according to the needs of your database.

Retrieving The Authenticated User

You may access the authenticated user via the Auth facade:

Alternatively, once a user is authenticated, you may access the authenticated user via an Illuminate\Http\Request instance. Remember, type-hinted classes will automatically be injected into your controller methods:

Determining If The Current User Is Authenticated

To determine if the user is already logged into your application, you may use the check method on the Auth facade, which will return true if the user is authenticated:

Protecting Routes

Route middleware can be used to only allow authenticated users to access a given route. Laravel ships with an auth middleware, which is defined at Illuminate\Auth\Middleware\Authenticate. Since this middleware is already registered in your HTTP kernel, all you need to do is attach the middleware to a route definition:

If you are using controllers, you may call the middleware method from the controller’s constructor instead of attaching it in the route definition directly:

Redirecting Unauthenticated Users

When the auth middleware detects an unauthorized user, it will redirect the user to the login named route. You may modify this behavior by updating the redirectTo function in your app/Http/Middleware/Authenticate.php file:

Specifying A Guard

When attaching the auth middleware to a route, you may also specify which guard should be used to authenticate the user. The guard specified should correspond to one of the keys in the guards array of your auth.php configuration file:

Password Confirmation

Sometimes, you may wish to require the user to confirm their password before accessing a specific area of your application. For example, you may require this before the user modifies any billing settings within the application.

To accomplish this, Laravel provides a password.confirm middleware. Attaching the password.confirm middleware to a route will redirect users to a screen where they need to confirm their password before they can continue:

After the user has successfully confirmed their password, the user is redirected to the route they originally tried to access. By default, after confirming their password, the user will not have to confirm their password again for three hours. You are free to customize the length of time before the user must re-confirm their password using the auth.password_timeout configuration option.

BOOTSTRAP Image Shapes and Buttons

PICTURES (Bootstrap Image Shapes)

Rounded Corners

The .img-rounded class adds rounded corners to an image (IE8 does not support rounded corners):

Example

<div class=“container”>

                    <h2>Rounded Corners</h2>        

                    <img src=“img/cinqueterre.jpg” class=“img-rounded” alt=“Cinque Terre” width=“304” height=“236”>

                  </div>  

 

Circle

The .img-circle class shapes the image to a circle (IE8 does not support rounded corners):

Example

<div class=“container”>

                    <h2>Rounded Corners</h2>        

                    <img src=“img/cinqueterre.jpg” class= img-circle “ alt=“Cinque Terre” width=“304” height=“236”>

                 </div>  

Thumbnail

The .img-thumbnail class shapes the image to a thumbnail:

Example

<div class=“container”>

                    <h2>Rounded Corners</h2>        

                    <img src=“img/cinqueterre.jpg” class= img- thumbnail “ alt=“Cinque Terre” width=“304” height=“236”>

                  </div>  

 

Responsive Images

Images come in all sizes. So do screens. Responsive images automatically adjust to fit the size of the screen.

Create responsive images by adding an .img-responsive class to the <img> tag. The image will then scale nicely to the parent element.

The .img-responsive class applies display: block; and max-width: 100%; and height: auto; to the image:

Example

 

<img class=”img-responsive” src=”img_chania.jpg” alt=”Chania”>

Responsive Embeds

Also let videos or slideshows scale properly on any device.

Classes can be applied directly to <iframe>, <embed>, <video>, and <object> elements.

The following example creates a responsive video by adding an .embed-responsive-item class to an <iframe> tag (the video will then scale nicely to the parent element). The containing <div> defines the aspect ratio of the video:

Example

 

<div class=”embed-responsive embed-responsive-16by9″>
  
<iframe class=”embed-responsive-item” src=”…”></iframe>
</div>

What is aspect ratio?

The aspect ratio of an image describes the proportional relationship between its width and its height. Two common video aspect ratios are 4:3 (the universal video format of the 20th century), and 16:9 (universal for HD television and European digital television).

 

You can choose between two aspect ratio classes:

 

<!– 16:9 aspect ratio –>
<div class=”embed-responsive embed-responsive-16by9″>
  
<iframe class=”embed-responsive-item” src=”…”></iframe>
</div>

<!– 4:3 aspect ratio –>
<div class=”embed-responsive embed-responsive-4by3″>
  
<iframe class=”embed-responsive-item” src=”…”></iframe>
</div>

For incase for any confusion, here is video to help you through diferrent image shapes and sizes in bootstrap

Bootstrap Buttons

Bootstrap provides different styles of bottons:

Button Styles

 

To achieve the button styles above, Bootstrap has the following classes:

  • .btn
  • .btn-default
  • .btn-primary
  • .btn-success
  • .btn-info
  • .btn-warning
  • .btn-danger
  • .btn-link

The following example shows the code for the different button styles:

Example

<button type=”button” class=”btn”>Basic</button>
<button type=”button” class=”btn btn-default”>Default</button>
<button type=”button” class=”btn btn-primary”>Primary</button>
<button type=”button” class=”btn btn-success”>Success</button>
<button type=”button” class=”btn btn-info”>Info</button>
<button type=”button” class=”btn btn-warning”>Warning</button>
<button type=”button” class=”btn btn-danger”>Danger</button>
<button type=”button” class=”btn btn-link”>Link</button>

 

The button classes can be used on an <a><button>, or <input> element:

Example

<a href=”#” class=”btn btn-info” role=”button”>Link Button</a>
<button type=”button” class=”btn btn-info”>Button</button>
<input type=”button” class=”btn btn-info” value=”Input Button”>
<input  type=”submit” class=”btn btn-info” value=”Submit Button”>

Button Sizes

Bootstrap provides four button sizes:

Large Medium Small XSmall

The classes that define the different sizes are:

  • .btn-lg
  • .btn-md
  • .btn-sm
  • .btn-xs

The following example shows the code for different button sizes:

Example

<button type=”button” class=”btn btn-primary btn-lg”>Large</button>
<button type=”button” class=”btn btn-primary btn-md”>Medium</button>
<button type=”button” class=”btn btn-primary btn-sm”>Small</button>
<button type=”button” class=”btn btn-primary btn-xs”>XSmall</button>

Block Level Buttons

A block level button spans the entire width of the parent element.

Button 1Button 2

Add class .btn-block to create a block level button:

Example

<button type=”button” class=”btn btn-primary btn-block”>Button 1</button>

Active/Disabled Buttons

A button can be set to an active (appear pressed) or a disabled (unclickable) state:

Active Primary Disabled Primary

The class .active makes a button appear pressed, and the class .disabled makes a button unclickable:

Example

 

<button type=”button” class=”btn btn-primary active”>Active Primary</button>
<button type=”button” class=”btn btn-primary disabled”>Disabled Primary</button>

A video to guide you through different button styles

Laravel Validations & Rules

Helllo once again, im back with an awesome topic. Today we going to be discussing Validations and Rules   

Introduction

Laravel provides several different approaches to validate your application’s incoming data. By default, Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate incoming HTTP request with a variety of powerful validation rules.

Validation Quickstart

To learn about Laravel’s powerful validation features, let’s look at a complete example of validating a form and displaying the error messages back to the user.

Defining The Routes

First, let’s assume we have the following routes defined in our routes/web.php file:

The GET route will display a form for the user to create a new blog post, while the POST route will store the new blog post in the database.

Creating The Controller

Next, let’s take a look at a simple controller that handles these routes. We’ll leave the store method empty for now:

Writing The Validation Logic

Now we are ready to fill in our store method with the logic to validate the new blog post. To do this, we will use the validate method provided by the Illuminate\Http\Request object. If the validation rules pass, your code will keep executing normally; however, if validation fails, an exception will be thrown and the proper error response will automatically be sent back to the user. In the case of a traditional HTTP request, a redirect response will be generated, while a JSON response will be sent for AJAX requests.

To get a better understanding of the validate method, let’s jump back into the store method:

As you can see, we pass the desired validation rules into the validate method. Again, if the validation fails, the proper response will automatically be generated. If the validation passes, our controller will continue executing normally.

Alternatively, validation rules may be specified as arrays of rules instead of a single | delimited string:

Stopping On First Validation Failure

Sometimes you may wish to stop running validation rules on an attribute after the first validation failure. To do so, assign the bail rule to the attribute:

Displaying The Validation Errors

In this example, if the unique rule on the title attribute fails, the max rule will not be checked. Rules will be validated in the order they are assigned.In this example, if the unique rule on the title attribute fails, the max rule will not be checked. Rules will be validated in the order they are assigned.

So, what if the incoming request parameters do not pass the given validation rules? As mentioned previously, Laravel will automatically redirect the user back to their previous location. In addition, all of the validation errors will automatically be flashed to the session.

Again, notice that we did not have to explicitly bind the error messages to the view in our GET route. This is because Laravel will check for errors in the session data, and automatically bind them to the view if they are available. The $errors variable will be an instance of Illuminate\Support\MessageBag. For more information on working with this object, check out its documentation.

The $errors variable is bound to the view by the Illuminate\View\Middleware\ShareErrorsFromSession middleware, which is provided by the web middleware group. When this middleware is applied an $errors variable will always be available in your views, allowing you to conveniently assume the $errors variable is always defined and can be safely used.

So, in our example, the user will be redirected to our controller’s create method when validation fails, allowing us to display the error messages in the view:

The @error Directive

You may also use the @error Blade directive to quickly check if validation error messages exist for a given attribute. Within an @error directive, you may echo the $message variable to display the error message:

Thats it for this week.

Please subscribe to our weekly blogs by clicking on this link : http://eepurl.com/gCkXan