Introduction of WordPress

WordPress is a free open source content management system. It is an online site which is based on PHP and MySQL. it was mainly designed as a blogging tool but now it is a versatile CMS. we can create simple blog and fullt operational website and also mobile application using WordPress.

It is considered as the easiest and most popular CMS tool due to its features. The main feature of WordPress is its versatility and feasibility to use. There is no use of coding and designing skills for creating a website on this. Even a non-technical person can also create a website with the help of WordPress easily.

WordPress was released on 27th may 2003 by its founders Mike Little and Matt Mullenweg.

WordPress Versions

VersionReleased dateMusicianPurpose
0.7May 27, 2003noneNumbering is continued with last release of b2
1.0Jan 3, 2004DavisAdditions of search engine friendly links
1.2May 22, 2004MingusPlugin support added
1.5Feb 17, 2005StrayhornAdded features to manage static page and theme system
2.0Dec 31, 2005DukeAdded features like rich editing, faster posting, image uploading and many more
2.1Jan 22, 2007EllaRedesigned interface, corrected security issues, improved editing tools and content management system
2.2May 16, 2007GetzWidget support for templates were added
2.3Sept 24, 2007DexterSome security fixes, added native tagging support and brought easy notification of updates
2.5Mar 29, 2008BreckerImproved systems like plugin, editor, multi-file upload, extended search
2.6Jul 15, 2008TynerMade WordPress as more powerful CMS, enables track changes to every post and page and allows posting from anywhere
2.7Dec 11, 2008ColtraneAdded automatic upgrade, administration interface redesigned fully
2.8June10,2009BakerRedesigned widget interface, added improvement in speed
2.9Dec 19, 2009CarmenAdded built-in image editor, global undo, batch plugin updating
3.0June17,2010TheloniousAdded a new theme APIs, new default theme “Twenty Ten”, new UI
3.1Feb23, 2011ReinhardtAdded admin bar which is displayed in all pages when admin is logged in, a new writing interface
3.2Jul 4, 2011GershwinMade WordPress faster and lighter seeing growing speed in WordPress community
3.3Dec 12, 2011SonnyFocus on making WordPress familiar for tablet users and beginners
3.4June13,2012GreenImprovements on theme customization and other minor changes
3.5Dec 11,2102Elvinnew theme “Twenty Twelve”, support for color picker, retina display
3.6Aug 1, 2013OscarNew theme “Twenty Thirteen”, autosave, post locking, admin enhancements

Older Supported Versions

VersionReleased dateMusicianPurpose
3.7Oct 24, 2013BasieAutomatic apply maintenance and security updates in background, recommendation of strong password
3.8Dec 12, 2013ParkerNew theme “Twenty Fourteen”, responsive for mobile devices, improved admin interface, easy main dashboard
3.9Apr 16, 2014SmithNew theme browser, improvements in live widget, header previews
4.0Sept 4, 2014BennyEasy language change, plugin compatibility with PHP 5.5 and MySQL 5.6
4.1Dec 18, 2014DinahNew theme “Twenty Fifteen”, vine embeds and distraction free writing
4.2Apr 23, 2015Powell“Press This” feature, emoji and improved character support
4.3Aug 18, 2015BillieMore focus on mobile users, improved customizer and better passwords
4.4Dec 8, 2015CliffordNew theme “Twenty Sixteen”, improved responsive images
4.5Apr 12, 2016ColemanAdded live responsive features, inline linking and some other updates

Latest Version

VersionReleased dateMusicianPurpose
4.6Aug 16, 2016PepperAdded native fonts, streamline updates and content recovery

Future Version

VersionReleased dateMusicianPurpose
4.7Dec 2016noneRelease is scheduled for December 2016

Reasons to use WordPress

  1. Anyone can design his/her own website without any designing skills.
  2. To create a website on WordPress we only need n Internet connection.
  3. It provides a wide range of themes.
  4. It provides many free plugins which add extra functionality to our websites.
  5. It is free and open source.
  6. Adding blog is very easy.
  7. It is very fate and secure.
  8. very easy to use.

How to create a WordPress website

Creating a site on WordPress is very easy. WordPress is designed in such a way that even non-tech users can also design their own websites easily and attractively.

Here, we’ll discuss each and every step involved in creating a WordPress site.

  • Selecting a right platform
  • Choosing a domain name and host
  • Choosing a theme/template
  • Creating new pages
  • Adding Content
  • Adding Media
  • Installing plugins

Selecting a right platform

First you have to decide a suitable platform to build your website with. Here platform means either you want to create your website using HTML, CSS or using a CMS (Content Management Systems).

There are various popular CMS in the market like WordPress, Drupal, Joomla, DotNetNuke, etc.

Why choosing WordPress

For a beginner WordPress will be the best as it doesn’t need any technical skills and due to its flexibility it is suited for all type of users.

You’ll get a lot of options to select a theme as a wide range of community design themes for WordPress. It can handle any type of website whether large or small. Most known websites like CNN, NASA, eBay use WordPress.

Above all, it gives you a responsive site which makes it compatible with small screen devices like mobile phones and tablets.

Shared hosting is best choice for beginners. You can later upgrade your site’s hosting according to the site’s traffic.


Choosing a domain name and host

You need a domain name and a hosting space to get your website online.

Domain name enables you to give your site your own name while hosting gives a space to your site on a server which makes sure your website loads quickly and won’t go down for hours.

Domain name should be short and easy to remember, brand able and catchy which defines your business.

Choosing a domain name is not easy with fulfilling all the criteria as million of domain names are active.


Choosing a theme/template

After installing WordPress, a site appears very plain. To make it more attractive, users install best suitable themes for their site. It adds visuals and views to the front page.

First of all, login to your WordPress site. By default, first screen will be your dashboard.

Accessing Free themes

After login, you’ll get access for 150 free themes.

Look at the above snapshot, to look at the free themes, got the side bar menu of your dashboard, select Appearance >Themes.

Below screen will appear including all the installed themes.

Look at the above snapshot, if you want to install more themes click on Add New button above and install it.

To install a theme, click on Install followed by Activate button.

Creating new pages

Look at the above snapshot, go the sidebar menu, click Pages > Add New option.

Adding Content

Adding new post

At the end we all will come to this point to make our site popular. We need to post different things to increase the popularity of our site.

Clicking on Post > Add New option, the above page will appear on the screen.

There are two ways to write a post, either you may write in Visual editor or in Text editor (in HTML format). Currently this snapshot is of Text editor.

Adding Categories

You can divide your content in different categories by adding categories to them. This tool is handy when you are publishing content for more than one field.

Click on Posts > Categories, you will be directed to the above page.

Here, in Name add a title to your new category. In Slug, you can add some words which will become part of URL while searching.

Tags

Tags are very much similar to Categories with only one difference that each post has its own set of tags.

Enabling or Disabling Comment

Comment creates a debate on some posts or sites. Some users don’t want their visitors to comment. They can shut comment off in WordPress.

To disable a comment for a particular page

  • Go to Pages > Add New
  • Click on Screen Options on top right
  • Tick on Discussions box
  • Scroll down, untick Allow Comments option.
  • Go to Settings > Discussions
  • Untick “Allow people to post comments on new articles”

Editing sidebar

Sidebar which generally appears on the right side (sometimes appears on left) contains widgets like Archives, Categories and Meta, etc.

To edit the side bar, go to Appearance > Widgets

Use drag n drop method to either use a widget or remove a widget.

Adding Media

Every website needs some photos and videos to describe its content and value. WordPress also provide functionality to add a media. You can add image caption, title and description along with media. Also add alt text helps search engine to identify the image.


Installing plugins

Plugins are the extensions in the WordPress with certain piece of coding expanding specific function to you site. They are not built-in.

There are almost 25,000 different plugins options to choose from.

Installation a plugin is very simple. Click Plugins. You will see three options, as shown in the snapshot below.

Click on Plugins > Add New. Following screen will appear in front of you.

You can choose a plugin from the given options. Just click Install Now and you will be able to use it.

DevOps Introduction

What is DevOps?

DevOps is the combination of two words, one is Development and other is operation. This allows a single person to handle the entire lifecycle of an application. DevOps helps in collaboration between Development and Operations team to deploy code to production faster. it helps to organization speed to deliver application and services. It is a sequence of development and it operation with better communication and collaboration.

Features of DevOps architecture:

  1. Automation

Automation reduces time consumption during testing and development phase. The productivity increases by automation. This will help in catching bugs so that it can be fixed easily.

2. Collaboration

The Development and Operations team collaborates as a DevOps team, which improves the cultural model as the teams become more productive with their productivity, which strengthens accountability and ownership. The teams share their responsibilities and work closely in sync, which in turn makes the deployment to production faster.

3. Integration

The Applications need to integrate with other components in the environment. In integration phase the existing code is combined with new code and tested. The continious integration and testing enables continious development.continious integration helps in to execute delivery in a quicker, safer and reliable manner.

4. Configuration management

It helps the application to interact with only those resources which are concerned with the environment.

Advantages of DevOps:-

  • It is a collective responsibility which help in better team engagement and productivity.
  • It improves customer satisfaction and experience.
  • It is an excellent approach of development and deployment.
  • DevOps respond faster to the market changes and improve bussiness and growth.
  • it places all the tools in the cloud for customer easy access.

Disadvantages of DevOps:-

  • Less availablity of DevOps professionals.
  • DevOps is expensive.
  • DevOps technology is hard to manage.

DevOps Architecture:-

1. Build

Without DevOps the cost of the consumption of the resource was evaluated based on the pre defined individualsusage with fixed hardware allocation. But DevOps usages the cloud for resource sharing, it is a mechanism to control usage of resources.

2. Code

Many good practices like Git helps in writing the code for bussiness, track changes, getting notified about the freason behind the changes and if necessary reverting to the original code developed.

3.Test

The application will be ready for production after testing. In the case of manual testing, it consumes more time in testing and moving the code to the output. The testing can be automated, which decreases the time for testing so that the time to deploy the code to production can be reduced as automating the running of the scripts will remove many manual steps.

4. Plan

Devops use Agile methodology to plan the development.

5. Monitor

Monitering is used to identify any risk of falilure. It also help in tracking the system accurately so that the health of the application can be monitered easily.

6. Deploy

Many systems can support the scheduler for automated deployment. The cloud management platform enables users to capture accurate insights and view the optimization scenario, analytics on trends by the deployment of dashboards.

7. Operate

The teams operate in a collaboration where both the teams actively participate throughout the services lifecycle.

8. Relaese

Deployment to an environment can be done by automation. But when the deployment is made to the production environment, it is done by manual triggering. many processes involved in release management commonly used to do the deployment in the production environment manually to lessen the impact on the customers.

Tagged : /

Intorduction to JavaScript-From Validation

What is form validation?

when we got to any of popular site to register, we notice that they provide feedback when we didn’t fill the data or filled in correct format. we will get message such as:-

“This field is requied(when we leave the field blank).”

“Please enter your phone number in the format XXXXX”(When the data entered is not in correct format).

“Please enter the valid email address.”( when the email entered is not in correct format).

” Password needs to be between 8 to 20 character long and must contain one upper case letter, one symbol and a number.”( A very specific data format is required for the data).

This is called form validation.

OR

Before submitting the data to the server, it is important to ensure that all the fieds are correctly filled. This is called client side validation. It help us to ensure that the data entered matches the requirement. If the data entered is incorrect or simply missing, the server send the data back to the client requesting to resubmit the form with correct data.

There are two types or validation:-

  1. Client side validation:- When the validation is done on the browser is called client side validation.
  2. Server side validation:- when then the validation is done on server is called server side validation.

Three main reasons of validation:

  1. We want to get the right data, in the right format.
  2. We want to protect our users data.
  3. We want to protect ourselves.

Different types of client side varification:-

There are two types of validation:-

  1. built-in form validation:– It uses the HTML5 validation features. This validation generally doesn’t require much JavaScript. Built-in form validation has better performance than JavaScript, but it is not customizable as JavaScript validation.
  2. JavaScript:- JavaScript validation is coded using JavaScript. this is completely customizable, but we need to create it or use a library.

Form validation performs 2 functions:-

  1. Basic validation:- In this validation the is checked that all the mandatary fields must be filled.
  2. Data Format Validation:- In this validation it is checked that all the filled data must be of correct form and value.

Using built-in form validation

One of the most significant features of html5 is the ability to validate user data without relying on JavaScript. This is done by using the validation attributes on form elements. Some of the attributes are written below:

  1. required: It specifies that whether a form field needs to be filled in before submitting.
  2. minlength: Specifies minimum length of the data.
  3. maxlength: Specifies the max length of the data.
  4. pattern: Specifies a regular expression that defines the entered data need to be follow.

Tagged : /

What is javascript

Introduction:-javascript is an object oriented programming language used by several websites for scripting  webpages. It is an interpreated programming language which enables dynamic interactivity on websites.

Features of javascript:-

1.all the websites support javascript, they provide built in execution environment.

2. it is a structured programming, it follows c programming language syntax and structure.

3. it is a case sensitive programming language.

4. it is a light weight interpreated language.

5. it is supportable in several operating system including macOS, windows etc.

Places to put JavaScript code:-

  1. Between head tag.
  2. Between body tag.
  3.  In external file(.js file)

javascriptComment:- it is a meaningful way to deliver messange,warning,suggestion or information about the code .

there are 2 types of javascript comment:

  1. Single-line comment
  2. Multi-line comment
  3. Single line comment:-  single line comment is used by adding forward slashes(//) before the line.
  4. Multi line comment:- it is represented by forward slash with asterisk then asterisk with forward slash.

Example:-/* code is here*/

JavaScript variable:- variable in javascript is a name of storage location.

There are 2 types of variables:-

  1. Local variable
  2. Global variable

Local variable:- Javascript local variable is declared inside the lock or function. It is accessible within the function or block.

Global variable:- It is declared outside the function and accessible from any function.

Javascript datatypes:-Datatypes hold different types of values.

There are two types of data types:-

  1. Primitive data type(string,number,Boolean undefined,null)
  2. Non-primitive data type(object,Array,RegExp)

Javascript operators:-

. javascript operators are the symbol which are used to perform operations on operands

1.Arithmetic Operators

2. Comparison (relational) operators

3. Bitwise Operators

4. logical Operatiors

5. Assignment Operators

6. Special Operators

Javascript if-else:

If else statement is used to execute wheather condition is true or false.

There are three forms of if ststements in javascript:-

  1. If statement
  2. If else statement
  3. If else if statement
Tagged :

HOW TO CREATE API IN LARAVEL

1st step:- open command prompt and go to xampp\htdocs folder and write the code given below in command prompt to create the project

Composer create-project –prefer-dist laravel/laravel admin “5.5.*”

2nd step:-now go to the project folder and make auth. Code is given below

               php artisan make:auth

3rd step:- Now install the passport. Write the code given below in command prompt.

    Composer required laravel/passport

4th step:-open phpmyadmin and make a database.

5th step:- open .env file and configure the database.

6th step:- Now migrate the database. Write the code given below in the command prompt

     php artisan migrate

7th step:-Add the code given below in user model.

       use Laravel\Passport\HasApiTokens;

8th step:- Add the code given below in auth service proviser(C:\xampp\htdocs\ admin\Providers\AuthorServiceProvider.php)

      use Laravel\Passport\Passport;

9th step:- Now configure auth.php(C:\xampp\htdocs\admin\config\auth.php)

Change the driver and provider as given below in api:-

‘api’=>[

‘driver’=>’passport’,

‘provider’=>’users’

],

10th step:- Add the code given below in kernel.php. (C:\xampp\htdocs\ admin\app\Http\Kernal.php)

Protected $routeMiddleware=[

‘client’_credentials’=>\Laravel\Passport\Http\Middleware\CheckClientcredentials::class,

11th step:-Add the code given below in app.php(config\app.php)

/*

   *Application Service Providers…

  */

 //Passport Service provider

    Laravel\Passport\PassportServiceprovider::class,

];

12th step:- Write the code given below in command prompt.

              php artisan passport:install

      Encryption keys generated successfully.

Tagged : / /

How to upload image in the database and send mail image

1st step:- Open command prompt in C:\xampp\htdocs.

2nd step:- Write the code given below in the opened command prompt to make laravel project.

   composer create-project --prefer-dist laravel/laravel ImageUpload "5.8.*"




3rd step:- After the project is created, open the folder in any code editor.

4th step:- Now open xampp. And make a database.

5th step:- Open the .env file of the project and change the name of the database same as defined in phpmyadmin.

6th step:- Write the code given below in command prompt to make controller.

php artisan make:controller ImageUpload

7th step:- Write the code given below in command prompt to make model.

  php artisan make:model ImageUpload –m

8th step:- write the name of the column of the databse in

database\migrations\2020_10_23_070450_create_ images _ upload _table.php

9th step:- Write the code given below in command prompt to migrate the table to the database.

                  php artisan migrate

10th step:-Then make view page in resource\views

Code of imageupload.blade.php

11th step:- Make one blade file resources/view/dynamic_email_template.blade.php

And paste the code given below:-

<p style=”margin-left:10%;”>First Name – <b>{{ $data[‘name’] }} </b></p>

<p style=”margin-left:10%;”>last Name – <b>{{ $data[’email’] }}  </b></p>

<p>It would be appriciative, if you gone through this feedback.</p>

12th step:- Go to web.php and make routes.

The code is given below:-

Route::get(‘sendemail’,’SendEmailController@index’);

Route::post(‘sendemail.store’,’SendEmailController@store’)->name(‘sendemail.store’);

13th step:- Go to controller and call model class

Paste the code given below below

14th step:- Now make the mail. Write the code given below in command prompt:-

php artisan make:mail SendMail

15th step:- Paste the code given below in the file made by the above command:-

16th step:- Make an account in mailtrap. 17th step.

17th step:- copy host, port, Username and password.

18th step:-configure .env file with the details copied by the mailtrap id.

19th step:- Now run the command given below in the terminal.

php artisan c:cache

php artisan serve

Tagged : / /

WHAT IS AJAX?

                                 

Introduction:- AJAX stands for Asynchronous Javascript And XML. AJAX is used for fast creating dynamic web pages. It allow web pages to be updated asynchronously by exchanging some amount of data with the server behind the scenes. It is possible to update some parts of a web page without reloading the whole page. There are many web applications that run on ajax example:- gmail,facebook,twitter,google map, youtube etc.

Understanding synchronous and asynchronous:-

Synchronous:- The synchronous request blocks the client until the operation completes.

Asynchronous:-  Asynchronous request doesn’t block the client. At the time when the request is processing, user can perform another operation.

Some AJAX technologies:-

As we know ajax is not a technology but group of inter related technologies.some of the technologies is given below:

1.HTML/XHTML and CSS

2.XML and JSON

3.DOM

4.XMLHttpRequest

5.javascript

  1. HTML/XHTML and CSS:- These are the technologies which are used for developing front end of a websites and styling.
  2. XML and JSON:- It is used for carrying data to and from the server
  3. DOM:- It is used for dynamic display and interaction with the data.
  4. XMLHttpRequest:- It is used for asynchronous communication between client and server .
  5. Javascript:-It is a text based programming language used client side and server side both. Javascript allows to make the web pages imteractive.

HOW AJAX WORKS:-

AJAX communicates with the server using XMLHttpRequest. The user sends the request from the UI and the javascript call goes to XMLHttpRequest object. Then the Http request is send to the server. Then the server interact with the database and data is retrived. The server sends te data to the XMLHttpRequest callback function. And HTML and CSS data is displayed on the browser.

Tagged : / / /

How to Create Multiple Role Based Authentication and Access control in Laravel 5.8

 

1st step:-open command prompt on xampp\htdocs directory.

2nd step:-Create laravel project with command given below

3rd step:- move to the project directory on command prompt.

4th step:-Write the command given below for user      Authentication

     php artisan make:auth

5th step:- write the given code in  (database/migration/2014_10_12_000000_create_user_table.php)

6th step:- create model and migration. Write the command given below in command prompt.

           php artisan make:model Role -m

7th step:- write the given code in  (database/migration/ 2020_06_10_060108_create_roles_table)

8th step:- In role model create users() function for relationship. Paste the code in Role.php file given below:-

9th step:- In user model create roles() function for relationship.

Paste the code in User.php file given below:-

10th step:- Now create seeder file for user. File name                UserTableSeeder. Write the command given below in command prompt to create UserTableSeeder:-

php artisan make:seed UsersTableSeeder

   11th step:- Now create seeder file for Role. File name                RoleTableSeeder. Write the command given below in command prompt to create RoleTableSeeder:-

        php artisan make:seed RolesTableSeeder

12th step:-Add insert function in RolesTableSeeder.php file(database/seeds/RolesTableSeeder.php)

Add DB file given below:-

use Illuminate\Support\Facades\DB;

Paste the code given below in RolesTableSeeder.php:-

13th step:-Add insert function in RolesTableSeeder.php file(database/seeds/UsersTableSeeder.php).

Add DB file given below:-

use Illuminate\Support\Facades\DB;

Paste the code given below in UsersTableSeeder.php:-

14th step:-Create Database in mysql.(database name=devopsschool)

15th step:- Go to .env file and set database=devopsschool,username=root

Code for .env file is given below:-

16th step:- Migrate the table to the database. Write the command given below in command prompt:-

php artisan migration

17th step:- Define RoletableSeeder and UserTableSeeder class on Database.php file. The code is given below:-

18th step:- insert datas in tables. Write the code given below in command prompt:

   php artisan db:seed

19th step:- create DashboardController for Admin. Write the code given below in command prompt:

php artisan make:controller Admin/DashboardController

20th step:- create DashboardController for Admin. Write the code given below in command prompt:

php artisan make:controller User/DashboardController

21st step:- create Adminmiddleware for Admin. Write the code given below in command prompt.

php artisan make:middleware AdminMiddleware

22nd step:- create Usermiddleware for User. Write the code given below in command prompt.

php artisan make:middleware UserMiddleware

23rd step:- Use Auth class for authentication in AdminMiddleware.php

24th step:- implement condition in handle() function of AdminMiddleware.php. Code of AdminMiddleware.php is given below:

25th step:- Use Auth class for authentication in UserMiddleware.php.

26th step:- :- Implement condition in handle() function of UserMiddleware.php. Code of UserMiddleware.php is given below:

27th step:-   Implement Condition for Admin and User Login in RedirectIfAuthenticated(app/Http/Middleware/RedirectIfAuthenticated.php). code given below:

28th step:- remove =/home from protected $redirectTo = ‘/home’; from (app/Http/Controllers/Auth/LoginController.php).

29th step:- implement condition in _construct() function in (app/Http/Controllers/Auth/LoginController.php).

 code given below:-

30th step:- remove =/home from protected $redirectTo = ‘/home’; from (app/Http/Controllers/Auth/LoginController.php).

31st step:- implement condition in _construct() function in (app/Http/Controllers/Auth/ResetPasswordController.php)

code given below:-

32nd step:- use AdminMiddleware in Kernal.php file

use App\Http\Middleware\AdminMiddleware;

33rd step:-Define AdminMiddleware in routemiddleware in kernel.php file

'admin' => AdminMiddleware::class,

34th step:- use UserMiddleware in Kernal.php file

use App\Http\Middleware\UserMiddleware;

35th step:- define UserMiddleware in routeMiddleware

'user' => UserMiddleware::class,

36th step:- set Admin middleware and Route. In (route/web.php)

37th step:- set user middleware and route. In (route/web.php)

Code of web.php file is given below:-

Tagged : /

LARAVEL CRUD

Laravel crud operation:-(version 5.8)

1st step:-First we have to download laravel (version-5.8).to download laravel we have to go to command prompt, and then go to the folder path in which you want to download laravel. After  this run the composer command.(command givel below):-

composer create-project laravel/laravel=5.8 crud –prefer-dist

2nd step:- After downloading laravel, we have to make MySql database.

3rd step:- now open .env file of the model and configure like the image given below:

4th step:- Make the migration folder by the writing the        command given below on command prompt:

      php artisan make:migration create_crud_table –create=crud

This command make a migration file in database\migration in this file we have to define the required column which we want to create in the database table.

The code for migration:-

                     <?php

use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class CreateCrudsTable extends Migration

{

    /**

     * Run the migrations.

     *

     * @return void

     */

    public function up()

    {

        Schema::create(‘cruds’, function (Blueprint $table) {

            $table->bigIncrements(‘id’);

            $table->string(‘first_name’);

            $table->string(‘last_name’);

            $table->string(‘image’);

            $table->timestamps();

        });

    }

    /**

     * Reverse the migrations.

     *

     * @return void

     */

    public function down()

    {

        Schema::dropIfExists(‘cruds’);

    }

}

Now we have to migrate the table to the database. The command to migrate the table to tahe database is:-

            Php artisan migrate

Write the above code in command prompt. 

5th step:- Now make a model by using the command

                 Php artisan make:moedel model_name –m

By the above command a new file is created with .php extension in app folder.

6th step:- Paste the code given below in the file created in               5th step

     <?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class crud extends Model

{

  protected $fillable =[

      ‘first_name’, ‘last_name’, ‘image’

  ];

}

7th step:- Now create controller. The code to create controller is given below

   Php artisan make:controller CrudController –resource

Note: crud of CrudController is name of the model.

8th step:- This is the most important step. In this step we set up the route for all the CrudController class  method. Write the below code in route\web.php file.

     <?php

/*

|————————————————————————–

| Web Routes

|————————————————————————–

|

| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the “web” middleware group. Now create something great!

|

*/

Route::get(‘/’, function () {

    return view(‘welcome’);

});

Route::resource(‘crud’,’CrudsController’);

9th step:- Now code the view file in resource\views folder. All the html,css and javascript code is written in this file.

We make new file for the view in resource\views\filename.blade.php

Code is given below

<!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>Document</title>

</head>

<body>

@extends(‘Crud.parent’)

@section(‘main’)

<div align=”right”>

    <a href=”{{route(‘crud.create’)}}”class=”btn btn-success btn-sm”>Add</a>

</div>

@if ($message = Session::get(‘success’))

<div class=”alert alert-success”>

<p>{{$message}}</p>

</div>

@endif

<table class=”table table-bordered table-striped”>

 <tr>

  <th width=”10%”>Image</th>

  <th width=”35%”>First Name</th>

  <th width=”35%”>Last Name</th>

  <th width=”30%”>Action</th>

 </tr>

 @foreach($data as $row)

  <tr>

   <td><img src=”{{ URL::to(‘/’) }}/images/{{ $row->image }}” class=”img-thumbnail” width=”75″ /></td>

   <td>{{ $row->first_name }}</td>

   <td>{{ $row->last_name }}</td>

   <td>

        <a href=”{{route(‘crud.show’, $row->id) }}” class=”btn btn-primary”>Show</a>

        <a href=”{{route(‘crud.edit’, $row->id) }}” class=”btn btn-warning”>Edit</a>

        <form action=”{{route(‘crud.destroy’,$row->id) }}”

        method=”post”>

        @csrf

        @method(‘DELETE’)

        <button type=”submit” class=”btn btn-danger”>Delete</button>

        </form>

   </td>

  </tr>

 @endforeach

</table>

{!! $data->links() !!}

@endsection

</body>

</html>

10th step:- Now code the controller.

 Code for the controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Crud;

class CrudsController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function index()

    {

        $data = Crud::latest()->paginate(5);

        return view(‘Crud.index’, compact(‘data’))

                ->with(‘i’, (request()->input(‘page’, 1) – 1) * 5);

    }

    /**

     * Show the form for creating a new resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function create()

    {

        return view(‘Crud.create’);

    }

    /**

     * Store a newly created resource in storage.

     *

     * @param  \Illuminate\Http\Request  $request

     * @return \Illuminate\Http\Response

     */

    public function store(Request $request)

    {

        $request->validate([

            ‘first_name’    =>  ‘required’,

            ‘last_name’     =>  ‘required’,

            ‘image’         =>  ‘required|image|max:2048’

        ]);

        $image = $request->file(‘image’);

        $new_name = rand() . ‘.’ . $image->getClientOriginalExtension();

        $image->move(public_path(‘images’), $new_name);

        $form_data = array(

            ‘first_name’       =>   $request->first_name,

            ‘last_name’        =>   $request->last_name,

            ‘image’            =>   $new_name

        );

        Crud::create($form_data);

        return redirect(‘crud’)->with(‘success’, ‘Data Added successfully.’);

    }

    /**

     * Display the specified resource.

     *

     * @param  int  $id

     * @return \Illuminate\Http\Response

     */

    public function show($id)

    {

        $data = Crud::findOrFail($id);

        return view(‘Crud.view’, compact(‘data’));

    }

    /**

     * Show the form for editing the specified resource.

     *

     * @param  int  $id

     * @return \Illuminate\Http\Response

     */

    public function edit($id)

    {

        $data = Crud::findOrFail($id);

        return view(‘Crud.edit’, compact(‘data’));

    }

    /**

     * Update the specified resource in storage.

     *

     * @param  \Illuminate\Http\Request  $request

     * @param  int  $id

     * @return \Illuminate\Http\Response

     */

    public function update(Request $request, $id)

    {

         $image_name = $request->hidden_image;

        $image = $request->file(‘image’);

        if($image != ”)

        {

            $request->validate([

                ‘first_name’    =>  ‘required’,

                ‘last_name’     =>  ‘required’,

                ‘image’         =>  ‘image|max:2048’

            ]);

            $image_name = rand() . ‘.’ . $image->getClientOriginalExtension();

            $image->move(public_path(‘images’), $image_name);

        }

        else

        {

            $request->validate([

                ‘first_name’    =>  ‘required’,

                ‘last_name’     =>  ‘required’

            ]);

        }

        $form_data = array(

            ‘first_name’       =>   $request->first_name,

            ‘last_name’        =>   $request->last_name,

            ‘image’            =>   $image_name

        );

        Crud::whereId($id)->update($form_data);

        return redirect(‘crud’)->with(‘success’, ‘Data is successfully updated’);

    }

    /**

     * Remove the specified resource from storage.

     *

     * @param  int  $id

     * @return \Illuminate\Http\Response

     */

    public function destroy($id)

    {

        $data = Crud::findOrFail($id);

        $data->delete();

        return redirect(‘crud’)->with(‘success’, ‘Data is successfully deleted’);

    }

}

Code for index file

resources/views/index.blade.php

<!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>Document</title>

</head>

<body>

@extends(‘Crud.parent’)

@section(‘main’)

<div align=”right”>

    <a href=”{{route(‘crud.create’)}}”class=”btn btn-success btn-sm”>Add</a>

</div>

@if ($message = Session::get(‘success’))

<div class=”alert alert-success”>

<p>{{$message}}</p>

</div>

@endif

<table class=”table table-bordered table-striped”>

 <tr>

  <th width=”10%”>Image</th>

  <th width=”35%”>First Name</th>

  <th width=”35%”>Last Name</th>

  <th width=”30%”>Action</th>

 </tr>

 @foreach($data as $row)

  <tr>

   <td><img src=”{{ URL::to(‘/’) }}/images/{{ $row->image }}” class=”img-thumbnail” width=”75″ /></td>

   <td>{{ $row->first_name }}</td>

   <td>{{ $row->last_name }}</td>

   <td>

        <a href=”{{route(‘crud.show’, $row->id) }}” class=”btn btn-primary”>Show</a>

        <a href=”{{route(‘crud.edit’, $row->id) }}” class=”btn btn-warning”>Edit</a>

        <form action=”{{route(‘crud.destroy’,$row->id) }}”

        method=”post”>

        @csrf

        @method(‘DELETE’)

        <button type=”submit” class=”btn btn-danger”>Delete</button>

        </form>

   </td>

  </tr>

 @endforeach

</table>

{!! $data->links() !!}

@endsection

</body>

</html>

Code for create file

resources/views/create.blade.php

   <!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>Document</title>

</head>

<body>

@extends(‘Crud.parent’)

@section(‘main’)

@if($errors->any())

<div class=”alert alert-danger”>

 <ul>

  @foreach($errors->all() as $error)

  <li>{{ $error }}</li>

  @endforeach

 </ul>

</div>

@endif

<div align=”right”>

 <a href=”{{ route(‘crud.index’) }}” class=”btn btn-default”>Back</a>

</div>

<form method=”post” action=”{{ route(‘crud.store’) }}” enctype=”multipart/form-data”>

 @csrf

 <div class=”form-group”>

  <label class=”col-md-4 text-right”>Enter First Name</label>

  <div class=”col-md-8″>

   <input type=”text” name=”first_name” class=”form-control input-lg” />

  </div>

 </div>

 <br />

 <br />

 <br />

 <div class=”form-group”>

  <label class=”col-md-4 text-right”>Enter Last Name</label>

  <div class=”col-md-8″>

   <input type=”text” name=”last_name” class=”form-control input-lg” />

  </div>

 </div>

 <br />

 <br />

 <br />

 <div class=”form-group”>

  <label class=”col-md-4 text-right”>Select Profile Image</label>

  <div class=”col-md-8″>

   <input type=”file” name=”image” />

  </div>

 </div>

 <br /><br /><br />

 <div class=”form-group text-center”>

  <input type=”submit” name=”add” class=”btn btn-primary input-lg” value=”Add” />

 </div>

</form>

@endsection

</body>

</html>

Code for view file

resources/views/view.blade.php

<!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>Document</title>

</head>

<body>

@extends(‘parent’)

@section(‘main’)

<div class=”jumbotron text-center”>

 <div allign=”right”>

  <a href=”{{ route(‘crud.index’) }}” class=”btn btn-default”>Back</a>

 </div>

 <br />

 <img src=”{{ URL::to(‘/’) }}/images/{{ $data->image }}” class=”img-thumbnail” />

 <h3>First Name – {{ $data->first_name }} </h3>

 <h3>Last Name – {{ $data->last_name }}</h3>

</div>

@endsection

</body>

</html>

  Code for edit file

resources/views/edit.blade.php

      <!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>Document</title>

</head>

<body>

@extends(‘parent’)

@section(‘main’)

            @if ($errors->any())

                <div class=”alert alert-danger”>

                    <ul>

                        @foreach ($errors->all() as $error)

                            <li>{{ $error }}</li>

                        @endforeach

                    </ul>

                </div>

            @endif

            <div align=”right”>

                <a href=”{{ route(‘crud.index’) }}” class=”btn btn-default”>Back</a>

            </div>

            <br />

     <form method=”post” action=”{{ route(‘crud.update’, $data->id) }}” enctype=”multipart/form-data”>

                @csrf

                @method(‘PATCH’)

      <div class=”form-group”>

       <label class=”col-md-4 text-right”>Enter First Name</label>

       <div class=”col-md-8″>

        <input type=”text” name=”first_name” value=”{{ $data->first_name }}” class=”form-control input-lg” />

       </div>

      </div>

      <br />

      <br />

      <br />

      <div class=”form-group”>

       <label class=”col-md-4 text-right”>Enter Last Name</label>

       <div class=”col-md-8″>

        <input type=”text” name=”last_name” value=”{{ $data->last_name }}” class=”form-control input-lg” />

       </div>

      </div>

      <br />

      <br />

      <br />

      <div class=”form-group”>

       <label class=”col-md-4 text-right”>Select Profile Image</label>

       <div class=”col-md-8″>

        <input type=”file” name=”image” />

              <img src=”{{ URL::to(‘/’) }}/images/{{ $data->image }}” class=”img-thumbnail” width=”100″ />

                        <input type=”hidden” name=”hidden_image” value=”{{ $data->image }}” />

       </div>

      </div>

      <br /><br /><br />

      <div class=”form-group text-center”>

       <input type=”submit” name=”edit” class=”btn btn-primary input-lg” value=”Edit”/>

      </div>

     </form>

@endsection

</body>

</html>

Bootstrap Tutorial

INTRODUCTION:-

Bootstrap is framework of HTML,CSS and JavaScript for developing responsive websites. It is free to use and download. It is front end framework which makes web development faster and easier. It have many HTML and CSS based templates for  forms,buttons,tables etc.

HISTORY:-

Bootstrap was developed by Mark Otto and Jacob Thorton. It was first released as an open source in August 2011.

ADVANTAGES:-

  1. Bootstrap is very easy to use.
  2. Anyone who have basic knowledge of HTML and CSS can use it very easily.
  3. It help users to develop responsive websites very easily.
  4. Bootstrap is compatible on most of the browser.

BOOTSTRAP CONTAINER:-

The container class is used to create boxed content.

Example:-

  1.         <html>  
  2.  <body>  
  3.   <div class=“container”>  
  4.    <div class=“row”>  
  5.      <div class=“col-md-xx”></div>  
  6.        …  
  7.    </div>  
  8.    <div class=“row”>  
  9.      <div class=“col-md-xx”></div>  
  10.        …  
  11.    </div>  
  12.   </div>  
  13.  </body>  
  14. </html>  

BOOTSTRAP JUMBTRON:-

The jumptron is used to specify big box for getting extra attention. It is a box with rounded corner. It is used in <div>.

Example:-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3. <head>  
  4.   <title>Bootstrap Example</title>  
  5.   <meta charset=“utf-8”>  
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>  
  7.   <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>  
  8. </head>  
  9. <body>  
  10.   
  11. <div class=“container”>  
  12.   <div class=“jumbotron”>  
  13.     <h1>This is Jumbotron inside container!</h1>        
  14.     <p>Jumbotron specifies a big box for getting extra attention to some special content or information.</p>  
  15.   </div>  
  16.   <p>This is some text.</p>        
  17.   <p>This is another text.</p>        
  18. </div>  
  19.   
  20.   <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>  
  21.   <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>  
  22. </body>  
  23. </html>

BOOTSTRAP BUTTONS:-

There are 7 buttons present in boot strap:

  1. .btn-primary
  2. .btn-default
  3. .btn-info
  4. .btn-danger
  5. .btn-link
  6. .btn-warning
  7. .success  

Example:-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3.   <head>  
  4.      <title>Job</title>  
  5.      <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>  
  6.   </head>  
  7.   <body>  
  8.     <h1>Button Example!</h1>  
  9.   
  10. <button class=“btn btn-default”>default</button>  
  11. <button class=“btn btn-primary”>primary</button>  
  12. <button class=“btn btn-danger”>danger</button>  
  13. <button class=“btn btn-success”>success</button>  
  14. <button class=“btn btn-info”>info</button>  
  15. <button class=“btn btn-warning”>warning</button>  
  16. <button class=“btn btn-link”>Link</button>  
  17.   
  18. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>
  19.   <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>  
  20.   </body>  
  21. </html>  

Classes for button size:-

  1. .btn-lg
  2. .btn-md
  3. .btn-sm
  4. .btn-xs

BOOTSTRAP TABLES:-

We can use bootstrap to design different types or table.

Example:-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3.   <head>  
  4.      <title>Job</title>  
  5.      <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>  
  6.   </head>  
  7.   <body>  
  8.   
  9. <div class=“container”>  
  10.   <h1>Basic Table Example</h1>  
  11.   
  12. <table class=“table”>  
  13.   <tr><th>Id</th><th>Name</th><th>Age</th></tr>  
  14.   <tr><td>101</td><td>Rahul</td><td>23</td></tr>  
  15.   <tr><td>102</td><td>Umesh</td><td>22</td></tr>  
  16.   <tr><td>103</td><td>Max</td><td>29</td></tr>  
  17.   <tr><td>104</td><td>Ajeet</td><td>21</td></tr>  
  18. </table>  
  19.   
  20. </div>  
  21.   
  22. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>  
  23.   <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>  
  24.   </body>  
  25. </html>  
  • <tr> is used for table row.
  • <td> is used for table data.
  • <th> is used for table heading.

BOOTSTRAP FORMS:-

There are three types of forms in bootstrap.

  1. Horizontal form
  2. Vertical form
  3. Inline form

Example 1( vertical form):-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3.   <head>  
  4.      <title>Bootstrap example</title>  
  5.      <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>  
  6.   </head>  
  7.   <body>  
  8.   
  9. <div class=“container”>  
  10.   <h1>Vertical Form Example</h1>  
  11.   
  12. <form style=“width:300px”>  
  13.   <div class=“form-group”>  
  14.     <label for=“exampleInputEmail1”>Email address</label>  
  15.     <input type=“email” class=“form-control” id=“exampleInputEmail1” placeholder=“Email”>  
  16.   </div>  
  17.   <div class=“form-group”>  
  18.     <label for=“exampleInputPassword1”>Password</label>  
  19.     <input type=“password” class=“form-control” id=“exampleInputPassword1” placeholder=“Password”>  
  20.   </div>  
  21.     
  22.   <button type=“submit” class=“btn btn-default”>Login</button>  
  23. </form>  
  24.   
  25. </div>  
  26.   
  27. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>  
  28.   <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>  
  29.   </body>  
  30. </html>  

Horizontal form:-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3. <head>  
  4.   <title>Bootstrap Example</title>  
  5.   <meta charset=“utf-8”>  
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>  
  7.   <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>  
  8.     
  9. </head>  
  10. <body>  
  11.   
  12. <div class=“container”>  
  13.   <h2>Horizontal form Example</h2>  
  14.   <form class=“form-horizontal” role=“form”>  
  15.     <form style=“width:300px”>  
  16.   <div class=“form-group”>  
  17.       <label class=“control-label col-sm-2” for=“email”>Email:</label>  
  18.       <div class=“col-sm-10”>  
  19.         <input type=“email” class=“form-control” id=“email” placeholder=“Enter email”>  
  20.       </div>  
  21.     </div>  
  22.     <div class=“form-group”>  
  23.       <label class=“control-label col-sm-2” for=“pwd”>Password:</label>  
  24.       <div class=“col-sm-10”>            
  25.         <input type=“password” class=“form-control” id=“pwd” placeholder=“Enter password”>  
  26.       </div>  
  27.     </div>  
  28.     
  29.   <div class=“form-group”>          
  30.       <div class=“col-sm-offset-2 col-sm-10”>  
  31.         <button type=“submit” class=“btn btn-default”>Submit</button>  
  32.       </div>  
  33.     </div>  
  34.   </form>  
  35. </div>  
  36. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>  
  37. <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>  
  38.   
  39. </body>  
  40. </html>  

Inline form:-

  1. <!DOCTYPE html>  
  2. <html lang=“en”>  
  3. <head>  
  4.   <title>Bootstrap Example</title>  
  5.   <meta charset=“utf-8”>  
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>  
  7.   <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>  
  8.     
  9. </head>  
  10. <body>  
  11.   
  12. <div class=“container”>  
  13.   <h2>Inline form Example</h2>  
  14.   <form class=“form-inline” role=“form”>  
  15.     <form style=“width:300px”>  
  16.   <div class=“form-group”>  
  17.     <label for=“exampleInputEmail1”>Email address</label>  
  18.     <input type=“email” class=“form-control” id=“exampleInputEmail1” placeholder=“Email”>  
  19.   </div>  
  20.   <div class=“form-group”>  
  21.     <label for=“exampleInputPassword1”>Password</label>  
  22.     <input type=“password” class=“form-control” id=“exampleInputPassword1” placeholder=“Password”>  
  23.   </div>  
  24.     
  25.   <button type=“submit” class=“btn btn-default”>Login</button>  
  26. </form>  
  27.   
  28. </div>  
  29. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>  
  30.   <script src=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>  
  31.   
  32. </body>  
  33. </html>