Tagged: php

PHP AJAX Live Search Box Autocomplete Using MySQL Database 0

PHP AJAX Live Search Box Autocomplete Using MySQL Database

Today, We want to share with you PHP AJAX Live Search Box Autocomplete Using MySQL Database.In this post we will show you PHP Jquery AJAX Live Search Box Using MySQL, hear for PHP MySQL Live Search Box using Jquery Ajax Example we will give you demo and example for implement.In this post, we will learn about Jquery Ajax Live Search Box using PHP MySql with an example.

PHP AJAX Live Search Box Autocomplete Using MySQL Database

There are the Following The simple About PHP AJAX Live Search Box Autocomplete Using MySQL Database Full Information With Example and source code.

As I will cover this Post with live Working example to develop ajax live data search using jquery php mysql, so the some major files and Directory structures for this example is following below.

  • index.php
  • fetch.php

Step 1: Creating the Database Table

— Database: `member_list` >> — Table structure for table `member_tbl`

CREATE TABLE IF NOT EXISTS `member_tbl` (
  `MemberID` int(11) NOT NULL AUTO_INCREMENT,
  `MemberName` varchar(250) NOT NULL,
  `member_addr` text NOT NULL,
  `member_city` varchar(250) NOT NULL,
  `member_pcode` varchar(30) NOT NULL,
  `member_country` varchar(100) NOT NULL,
  PRIMARY KEY (`MemberID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

Step 2: Dumping data On Table

Dumping data for table `member_tbl`

//ajax live data search using jquery php mysql
INSERT INTO `member_tbl` (`MemberID`, `MemberName`, `member_addr`, `member_city`, `member_pcode`, `member_country`) VALUES
(1, 'Jaydeep Gondaliya', 'sejal Str. 57', 'Berlin', '12209', 'Germany'),
(2, 'Ankit Kathiriya', 'Avda. de la Ram park 2222', 'USA D.F.', '5021', 'USA'),
(3, 'Krunal Sisodiya', 'sardha 2312', 'USA D.F.', '5475', 'USA'),
(4, 'chirag dethariya', '120 dsp salon Sq.', 'London', 'WA1 1DP', 'UK'),
(5, 'Dhaval dave', 'Rua do Ganesh, 12', 'Resende', '56458-363', 'UEA'),
(6, 'Pooja solanki', 'ul. astha 68', 'Walla', '01-658', 'Poland'),
(7, 'Bhakti Banugariya', 'kavya 45', 'Helsinki', '2853', 'India'),
(8, 'Nilesh chandvadiya', '305 - 14th Ave. S. Suite 3B', 'Seattle', '98128', 'USA'),
(9, 'Hitesh Ajani', 'Rua do Ganesh, 12', 'Resende', '098952-363', 'UEA'),
(10, 'Mayur Dhameliya', 'bhakti 38', 'Oulu', '321452', 'India'),
(11, 'Stavan Patel', '2, rue du chandni', 'Reims', '350024', 'France'),
(12, 'Parag shukla', '722 Titupati Blvd.', 'Kirkland', '360002', 'USA'),
(13, 'Vijay bhanderi', 'Bhavanath. 48', 'Butte', '225010', 'USA');

Step 3: Creating the Search Form

index.php

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

 
  
  <title>PHP AJAX Live Search Box Autocomplete Using MySQL Database</title>
  
  
  
 
 
  <div class="pakainfo container">
   <br />
   <h2 align="center">PHP AJAX Live Search Box Autocomplete Using MySQL Database</h2>
   
   <b>Simple ajax live data search using jquery php mysql</b><br />
   <div class="pakainfo form-group">
    <div class="input-group pakainfo">
     <span class="input-group-addon pakainfo">Search</span>
     
    </div>
   </div>
   <br />
   <div id="result"></div>
  </div>
 


$(document).ready(function(){

 ajax_data_load();

 function ajax_data_load(query)
 {
  $.ajax({
   url:"fetch.php",
   method:"POST",
   data:{query:query},
   success:function(data)
   {
    $('#result').html(data);
   }
  });
 }
 $('#query_search').keyup(function(){
  var search = $(this).val();
  if(search != '')
  {
   ajax_data_load(search);
  }
  else
  {
   ajax_data_load();
  }
 });
});

Step 4 : Processing Search Query in Backend

fetch.php for PHP AJAX Live Search Box Autocomplete server side source code

 0)
{
 $output .= '
  <div class="pakainfo table-responsive">
   <table class="table table bordered">
    <tr>
     <th>Member Name</th>
     <th>member Address</th>
     <th>member_city</th>
     <th>Member Post Code</th>
     <th>member_country</th>
    </tr>
 ';
 while($memres = mysqli_fetch_array($result))
 {
  $output .= '
   <tr>
    <td>'.$memres["MemberName"].'</td>
    <td>'.$memres["member_addr"].'</td>
    <td>'.$memres["member_city"].'</td>
    <td>'.$memres["member_pcode"].'</td>
    <td>'.$memres["member_country"].'</td>
   </tr>
  ';
 }
 echo $output;
}
else
{
 echo 'Data Not Found';
}

?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP AJAX Live Search Box Autocomplete Using MySQL Database.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Fetch Last week month year records in MySQL 0

Fetch Last week month year records in MySQL

Today, We want to share with you Fetch Last week month year records in MySQL.In this post we will show you How to fetch this week records in MySql ?, hear for SELECT IN MYSQL CURRENT DAY, CURRENT WEEK, LAST WEEK we will give you demo and example for implement.In this post, we will learn about Last one week, month, year record from date field by DATE_SUB with an example.

Fetch Last week month year records in MySQL

There are the Following The simple About Fetch Last week month year records in MySQL Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Get Last 7 days month year record from MySQL, so the get this week records mysql,fetch current week records mysql for this example is following below.

If We require to get all the MySQL Database records of current week using mysql query. for example We have one SQL table “products” as well as all the columns are product_id, product_title, product_description, created_at as well as update_at timestemp, And then We need to fetch all records of this week. therefor We can fetch all the fields value using DATE_SUB and INTERVAL of simple mysql Table. In following simple example We can display how to MySQL select data of fetch current week.

SELECT * FROM products WHERE created_at > DATE_SUB(NOW(), INTERVAL 1 WEEK);

Last 10 days records

select * from products where  `date` >= DATE_SUB(CURDATE(), INTERVAL 10 DAY)

DATE_SUB() Fetch the recent one month or year records from PHP MySQL table

SELECT DATE_SUB(  '2019-12-25', INTERVAL 3 DAY )

Present Month Records

SELECT * FROM `products` WHERE  date between  DATE_FORMAT(CURDATE() ,'%Y-%m-01') AND CURDATE()

Present Year Records

SELECT * FROM `products` WHERE  date between  DATE_FORMAT(CURDATE() ,'%Y-01-01') AND CURDATE()

Last one month records

select * from products where  `date` >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)

Records of two date ranges

select * from products where `date` BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 3 MONTH ) AND DATE_SUB( CURDATE( ) ,INTERVAL 0 MONTH )

Fetch records between 6 month and 12 month

select * from products where `date` BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 12  MONTH ) AND DATE_SUB( CURDATE( ) ,INTERVAL 6 MONTH )

MYSQL CURRENT DAY

SELECT IN MYSQL CURRENT DAY, CURRENT WEEK, LAST WEEK

Selecting MySQL records for the current day:

SELECT *
FROM (`products`)
WHERE date = CURDATE()  

MYSQL CURRENT week

SELECT IN MYSQL CURRENT DAY, CURRENT WEEK, LAST WEEK

Selecting MySQL records for the current week:

SELECT SUM(o_price) price
FROM (`orders`)
WHERE YEARWEEK(`o_date`) = YEARWEEK(CURDATE()) 

MYSQL CURRENT week

SELECT IN MYSQL CURRENT DAY, CURRENT WEEK, LAST WEEK

Selecting MySQL records for the current week:

SELECT *
FROM (
`products`
)
WHERE YEARWEEK( `date` ) = YEARWEEK( CURDATE( ) + INTERVAL 1 WEEK )
LIMIT 0 , 30

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Fetch Last week month year records in MySQL.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Eloquent query where exists MySQL 0

Laravel Eloquent query where exists

Today, We want to share with you Laravel Eloquent query where exists.In this post we will show you Laravel 5 query builder where exists example, hear for Check If A Database Table Exists With Laravel we will give you demo and example for implement.In this post, we will learn about Laravel Advance Database Query Builder with an example.

Laravel Eloquent query where exists

There are the Following The simple About Laravel Eloquent query where exists Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP SQL exists in Laravel 5 query builder, so the Laravel Eloquent – WhereNotExists for this example is following below.

We use simple Code PHP sql where exists clause in check laravel. whereExists through We can use Database in sql where exists clause in Latest version of the laravel Web project. It is simple and very easy to use as well as We can best way to implements and undestand. We can give simple fire SELECT statment in where some condition. We can see bellow source code with example as well as We can learn how to use simple whereExists in your Laravel app.

Simple SQL Query

SELECT *
FROM `products`
WHERE EXISTS
    (SELECT `products_cat`.`id`
     FROM `products_cat`
     WHERE products_cat.cat_id = products.id)

MySQL Using Laravel Query Builder

DB::table('products')
    ->whereExists(function ($query) {
        $query->select("products_cat.id")
              ->from('products_cat')
              ->whereRaw('products_cat.cat_id = products.id');
    })
    ->get();

Example 2: SQL exists in Laravel 5 query builder

$product = Products::whereNotExists(function ($query) use ($id_merchant) {
	$query->select(DB::raw(1))
		  ->from('merchant_poeni')
		  ->where('product.id', '=', 'a.id')
		  ->where('product_id', '=', $id_merchant);
})
->orderBy('created_at')
->first();

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Eloquent query where exists.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Chosen Ajax Autocomplete Textbox using jQuery, PHP 0

Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL

Today, We want to share with you Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL.In this post we will show you Autocomplete Textbox using jQuery, PHP and MySQLi, hear for Ajax PHP MySQL Creating Autocomplete Search Suggestion we will give you demo and example for implement.In this post, we will learn about PHP Autocomplete Input tags with Dynamic Data using jquery Ajax
with an example.

Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL

There are the Following The simple About Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL Full Information With Example and source code.

As I will cover this Post with live Working example to develop Jquery Chosen plugin – dynamically populate list by Ajax, so the PHP – Jquery Chosen Ajax Autocomplete for this example is following below.

Step 1: Make a MySQL Database Table

Lest start, I want to make MySQL database and table, therefor here i made “products” database and “products” table with product id as well as product name column. We can simply make MySQL “products” table as following simple sql query.

SQL Query:

CREATE TABLE IF NOT EXISTS `products` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=24 ;

Step 2: Make index.php

Now, I want to make simple root PHP index.php file as well as i made form with one HTML input text box using jquery chosen. I also some easy source code for multiple add more fields in jquery examples. therefor let’s make simple index.php file and put some bellow source code.

index.php

<!DOCTYPE html>
<html>
<head>
  <title>jQuery Chosen autocomplete with PHP and AJAX - pakainfo.com</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />

 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>

<h1>jQuery Chosen autocomplete with PHP and AJAX</h1> 
<div class="container pakainfo">
  <div class="pakainfo panel panel-primary">
    <div class="panel-heading">jQuery Chosen autocomplete with PHP and AJAX - pakainfo.com</div>
    <div class="panel-body pakainfo">
      <form>
        <select class="form-control pakainfo select-box">
          <option>Select Products</option>
        </select>
      </form>
    </div>
  </div>
</div>
 
<script type="text/javascript">
  $(".select-box").chosen();
 
  $('.chosen-search input').autocomplete({
    source: function( request, response ) {
      $.ajax({
        url: "request_ajax.php?name="+request.term,
        dataType: "json",
        success: function( data ) {
          $('.select-box').empty();
          response( $.map( data, function( product ) {
            $('.select-box').append('<option value="'+product.id+'">' + product.name + '</option>');
          }));
          $(".select-box").trigger("chosen:updated");
        }
      });
    }
  });
</script>
 
</body>
</html>

Step 3: Create request_ajax.php File

In this Last step, I shall simple source code for fetching PHP jquery ajax data from MySQL database using simple mysql query. Therefor We have to make a simple request_ajax.php and put bellow some source code:

request_ajax.php

<?php
    
    $hostName = "localhost";
    $username = "root";
    $password = "jaydeepGondaliya";
    $dbname = "products";
 
    $mysqli = new mysqli($hostName, $username, $password, $dbname); 
    $sql = "SELECT * FROM products WHERE name LIKE '%".$_GET['name']."%'"; 
    $all_result = $mysqli->query($sql);
 
    $data_response = [];
    while($row = mysqli_fetch_assoc($all_result)){
       $data_response[] = array("id"=>$row['id'], "name"=>$row['name']);
    } 
    echo json_encode($data_response);
 
?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Upload Import CSV Data Into MySQL Database 0

Laravel Upload Import CSV Data Into MySQL Database

Today, We want to share with you Laravel Upload Import CSV Data Into MySQL Database.In this post we will show you Laravel Upload csv file and import to Database with Php, hear for Upload CSV file and import it to database using Laravel we will give you demo and example for implement.In this post, we will learn about How to Import and Export CSV Files Using PHP Laravel and MySQL with an example.

Laravel Upload Import CSV Data Into MySQL Database

There are the Following The simple About Laravel Upload Import CSV Data Into MySQL Database Full Information With Example and source code.

As I will cover this Post with live Working example to develop Import CSV Data to MySQL Database with Laravel, so the csv file upload in laravel, how to csv file in laravel for this example is following below.

Laravel Model(laravel seed from csv)

app/Product.php

namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
	public $fillable = ['name','dedcription',’price’];
}

laravel import csv to database using Route

First of all simple Laravel create a route in routes.php, file. After than in this Laravel route you can put simple CSV functionality or you can make a function within a Laravel controller to read csv file(php import csv).

app/Http/routes.php

    Route::get('read-excel',function(){
		$dataAll = fopen('pakainfo-product.csv',"r");
		$column=fgetcsv($dataAll);
		while(!feof($dataAll)){
		$productsData[]=fgetcsv($dataAll);
		}
		foreach ($productsData as $key => $value) {
			$pcreate_data=array('name'=>$value[0],
			'details'=>$value[1],
			);
			Product::create($pcreate_data);
		}
		print_r($productsData);
    });

Angular 6 CRUD Operations Application Tutorials

Read :

Tags : csv file upload in laravel, how to csv file in laravel, laravel csv upload, laravel php csv upload, upload csv file in laravel, upload csv in laravel, laravel upload csv file, laravel, php, post

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Upload Import CSV Data Into MySQL Database.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Top 5 Best php PDF Generation libraries 0

Top 5 Best php PDF Generation libraries

Today, We want to share with you Top 5 Best php PDF Generation libraries.In this post we will show you generate pdf file in php Source code, hear for Best open source PDF generation libraries for PHP we will give you demo and example for implement.In this post, we will learn about PDF generation libraries : open source PDF generation libraries -PHP with an example.

Top 5 Best php PDF Generation libraries

There are the Following The simple About Top 5 Best php PDF Generation libraries Full Information With Example and source code.

As I will cover this Post with live Working example to develop Top 5 : Best open source PDF generation libraries for PHP, so the some major fpdf, mpdf php, tcpdf for this example is following below.

There are The List of the best php pdf libraries Like as a (FPDF, )

5. FPDF

generate pdf file in php code

A basic example of using PHP FPDF is with the following PHP source code (you must simple extract the FPDF libraries package in the directory where FPDF the PHP file with the source code is located):

<?php
require('fpdf/fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',20);
$pdf->Cell(50,10,'Pakainfo.com!');
$pdf->Output();
?>

Create PDF file with PHP using FPDF

best php pdf library

<?php
require('classes/fpdf/fpdf.php'); 
class PDF extends FPDF {
 
function Header() {
    $this->SetFont('Times','',12);
    $this->SetY(0.25);
    $this->Cell(0, .25, "Jaydeep Gondaliya ".$this->PageNo(), 'T', 2, "R");
    //reset Y
    $this->SetY(1);
}
 
function Footer() {
    $this->Image("pakainfo_logo.jpg", (8.5/2)-1.5, 9.8, 3, 1, "JPG", "https://www.pakainfo.com");
}
 
}
 
$pdf=new PDF("P","in","Letter");
 
$pdf->SetMargins(1,1,1);
 
$pdf->AddPage();
$pdf->SetFont('Times','',12);
 
$paragraph1=".";
$paragraph2=".";
$paragraph3 =".";
  
$pdf->SetFillColor(240, 100, 100);
$pdf->SetFont('Times','BU',12);
  
$pdf->Cell(0, .25, "paragraph", 1, 2, "C", 1);
  
$pdf->SetFont('Times','',12);
$pdf->MultiCell(0, 0.5, $paragraph1, 'LR', "L");
$pdf->MultiCell(0, 0.25, $paragraph2, 1, "R");
$pdf->MultiCell(0, 0.15, $paragraph3, 'B', "J");
 
$pdf->AddPage();
$pdf->Write(0.5, $paragraph1.$paragraph2.$paragraph3);
  
$pdf->Output();
?>

4. mPDF

mPDF

<?php
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new mPDF();

$mpdf->WriteHTML('<h1>Welcome To Pakainfo.com</h1><br><p>My first Pakainfo Blogs PDF with mPDF From Jaydeep Gondaliya</p>');

$mpdf->Output();
?>

3. DOMPDF

DOMPDF

<?php
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>Welcome To Pakainfo.com Demo</h1><br><p>Jaydeep Gondaliya!</p>');

$dompdf->setPaper('A4', 'portrait');

$dompdf->render();

$dompdf->stream();

2. Snappy (wkhtmltopdf)

Snappy

<?php

require __DIR__ . '/vendor/autoload.php';

use Knp\Snappy\Pdf;

$snappy = new Pdf('wkhtmltopdf.exe');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="myfile.pdf"');
echo $snappy->getOutput('https://www.pakainfo.com');

1. TCPDF

generate pdf in php example
1. TCPDF

<?php 
require_once('tcpdf_include.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Our Code World');
$pdf->SetTitle('Example Write Html');

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);


$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$pdf->AddPage();

$html = '<h4>PDF Example</h4><br><p>Welcome to the Pakainfo.com</p>';
 
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->AddPage();

$html = '<h1>Welcome</h1>';
$pdf->writeHTML($html, true, false, true, false, '');

$pdf->lastPage();
$pdf->Output('example_006.pdf', 'I');

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Top 5 Best php PDF Generation libraries.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Concept of Encapsulation in PHP OOP Example 0

Concept of Encapsulation in PHP OOP

Today, We want to share with you Encapsulation in PHP.
In this post we will show you What is OOP in PHP Encapsulation?, hear for encapsulation code example in php we will give you demo and example for implement.
In this post, we will learn about PHP Encapsulation, Polymorphism and Inheritance with an example.

Concept of Encapsulation in PHP?

Encapsulation is simple an OOP (Object Oriented Programming) Basic Funda in PHP.

Wrapping some binding data in main block single section is meanning of an Encapsulation. PHP Encapsulation is used to very safe to protection more data or details in an object from some This simple encapsulation is mainly used for security or protection supported.

Syntax of Encapsulation in PHP OOP

class Technology{
mobile(); // calling function of mobile
ComputerBook(); //calling function of Computer book
}

Defination of An Encapsulation in PHP

Now Encapsulation in PHP,Encapsulation is a Basic funda of data wrapping up or some data binding up more relabants data useful methods and members in a one or single module called as encapsulation

Example of Encapsulation in PHP OOP

_user == null ) {
               $this->_user = new Client();
          }
          return $this->_user;
     }

}

class Client {
     private $_name;

     public function __construct() {
          $this->_name = "Jaydeep Gondalita JG.";
     }

     public function ReadName() {
          return $this->_name;
     }
}

$app = new App();

echo $app->Client()->ReadName();

?>

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Concept of Encapsulation in PHP OOP.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

You can also read about AngularJS, ASP.NET, VueJs, PHP.

PHP Laravel Autocomplete search from Database Example 0

PHP Laravel Autocomplete search from Database Example Tutorial

Today, We want to share with you PHP Laravel Autocomplete search from Database Example Tutorial.In this post we will show you Autocomplete Textbox using jQuery, PHP, Laravel and MySQL, hear for Laravel Ajax Autocomplete Search from Database Example we will give you demo and example for implement.In this post, we will learn about Laravel Autocomplete using Bootstrap Typeahead JS Example with Demo with an example.

PHP Laravel Autocomplete search from Database Example Tutorial

There are the Following The simple About PHP Laravel Autocomplete search from Database Example Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop Manual Laravel Autocomplete search from Database, so the Laravel Ajax Autocomplete Search from Database for this example is following below.

  • Define routes
  • Set up controllers
  • changes the view
  • Step 1 : Create a Laravel routes

    first of all toy need to Define a Laravel route in main file web.php to showing New HTML search form,

    route/web.php

    Route::view('/find', 'find');
    

    Include a Laravel search route

    Route::get('/member/find', '[email protected]');
    

    Step 2 : Set up controllers

    make a Laravel LiveFindController

    LiveFindController

    public function searchMembers(Request $request)
    {
        return Member::where('name', 'LIKE', '%'.$request->q.'%')->get();
    }
    

    Step 3 :changes the view Blade files

    Path : resources/views/find.blade.php

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="www.pakainfo.com">
        <meta name="author" content="sapnesh_naik">
        <title>Autocomplete Search Bar in Laravel with Typehead.js - Laravel Search Autocomplete tutorial</title>
        <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
        <link href="{{asset('starter-template.css')}}" rel="stylesheet">
         <style>
            .twitter-typeahead,
            .tt-hint,
            .tt-input,
            .tt-menu{
                width: auto ! important;
                font-weight: normal;
    
            }
         </style>
      </head>
      <body>
    
        <div class="pakainfo container">
          <div class="starter-template pakainfo" style="align-text:right">
            <h1>Laravel Search Autocomplete - Laravel Autocomplete Search from database using jQuery</h1>
            <p>Laravel Autocomplete using Bootstrap Typeahead JS Example with Demo</p>
            <br>
            <input type="text" id="find" placeholder="Type to find members" autocomplete="off" >
          </div>
    
        </div>
        <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
        <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    
    
        <script src="//twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script>
        <script>
            $(document).ready(function() {
                var bloodhound = new Bloodhound({
                    datumTokenizer: Bloodhound.tokenizers.whitespace,
                    queryTokenizer: Bloodhound.tokenizers.whitespace,
                    remote: {
                        url: '/member/find?q=%QUERY%',
                        wildcard: '%QUERY%'
                    },
                });
    
                $('#find').typeahead({
                    hint: true,
                    highlight: true,
                    minLength: 1
                }, {
                    name: 'members',
                    source: bloodhound,
                    display: function(data) {
                        return data.name  //here HTML Input value one by one to be changes and set when you choose a suggestion for Laravel autocomplete search with typeahead.js.
                    },
                    templates: {
                        empty: [
                            '<div class="pakainfo list-group find-results-dropdown"><div class="pakainfo list-group-item">Nothing found.</div></div>'
                        ],
                        header: [
                            '<div class="pakainfo list-group find-results-dropdown">'
                        ],
                        suggestion: function(data) {
                        return '<div style="font-weight:normal; margin-top:-15px ! important;" class="pakainfo list-group-item">' + data.name + '</div></div>'
                        }
                    }
                });
            });
        </script>
    
      </body>
    </html>
    

    Angular 6 CRUD Operations Application Tutorials

    Read :

    Related Search : laravel autocomplete search bootstrap, laravel autocomplete jquery, laravel jquery autocomplete json, laravel autocomplete typeahead, laravel autocomplete from database, autocomplete typeahead bootstrap laravel

    Summary

    You can also read about AngularJS, ASP.NET, VueJs, PHP.

    I hope you get an idea about PHP Laravel Autocomplete search from Database Example Tutorial.
    I would like to have feedback on my Pakainfo.com blog.
    Your valuable feedback, question, or comments about this article are always welcome.
    If you enjoyed and liked this post, don’t forget to share.

    Laravel Tips Tricks and Techniques for Developers 0

    Laravel Tips Tricks and Techniques for Developers

    Today, We want to share with you Laravel Tips Tricks and Techniques for Developers.In this post we will show you 5+ Useful Laravel tips for beginners, hear for Tips, Tricks, and Practices with Laravel’s Eloquent we will give you demo and example for implement.In this post, we will learn about 5 Advanced Laravel Tips That Only Expert Laravel Developers Know with an example.

    Laravel Tips Tricks and Techniques for Developers

    There are the Following The simple About Laravel Tips Tricks and Techniques for Developers Full Information With Example and source code.

    As I will cover this Post with live Working example to develop Laravel, PHP, Angular tips and tricks, so the some Top 5 Laravel Tips for Developers for this example is following below.

    • laravel clear view cache
    • storage path permission in laravel
    • Access-Control-Allow-Origin in Laravel
    • Laravel group by date only
    • Laravel Join Multiple table

    Tip 1 : laravel 5, 5.5, 5.6, 5.7 clear view cache

    Issue: Blade view not reflecting changes

    Generally, The Laravel cached view files are simple your roor stored in path storage/framework/views.

    Run this command from Your terminal

    php artisan view:clear
    
    //Clear the Laravel cache as well as clear the cached view All the blade files:
    php artisan cache:clear
    php artisan config:clear
    php artisan view:clear
    

    Tip 2 : Changing storage path permission in laravel

    Issue: Fixing Permission denied Error in Laravel

    There are Two Commands run To your issue(chmod – Setting correct permissions) Fixed

    sudo chmod -R 777 storage/
    sudo chmod -R 777 bootstrap/cache/
    

    Tip 3 : Access-Control-Allow-Origin in Laravel

    Adding Access-Control-Allow-Origin header response in Laravel 5, 5.6, 5.7

    Issue: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. (In Laravel), set the Access-Control-Allow-Origin header to localhost or *.

    Add the following code to bootstrap/app.php:

    //bootstrap/app.php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: *');
    header('Access-Control-Allow-Headers: *');
    

    Tip 4: group by date only and get count in Laravel

    Laravel group by date to month only and get count

    public function membersmonthly(Request $request){
    
        $monthlymembers=DB::table('tbl_invs')
         ->select(DB::raw('sum(total) as total'),DB::raw('date(created_at) as dates'))
         ->groupBy('dates')
         ->orderBy('dates','desc')
        ->get();
    
    
        // dd($monthlymembers);
        return view('reports.monthlymembers', compact('monthlymembers'));
    }
    

    Tip 5: Laravel Join Multiple table using eloquent model

    How to join (Two or more – Multiple)three table by laravel 5, 5.5,5.6.5.7 eloquent model

    //1) Book.php 
    <?php
    
    namespace App\Models;
     use Eloquent;
    
    class Book extends Eloquent{
    
        protected $table = 'books';
    
        public function student()
        {
            return $this->belongsTo('App\Models\Student');
        }
    
        public function subject()
        {
            return $this->belongsTo('App\Models\Subject');
        }
    
    }
    
    //2) Subject.php 
    <?php
    
    namespace App\Models;
    
    use Eloquent;
    
    class Subject extends Eloquent
    {
        protected $table = "subjects";
    
        public function books()
        {
            return $this->hasMany('App\Models\Book');
        }
    
    }
    
    //3) Student.php
    <?php
    
    namespace App\Models;
    use Eloquent;
    
    class Student extends Eloquent
    {
        protected $table = 'students';
    
        public function books()
        {
            return $this->hasMany('App\Models\Book');
        }
    
    }
    
    

    Case 1 : Get an book by using the student and subject

    $book = \App\Models\Book::with(['student','subject'])->first();
    

    Case 2 : Get student name

    $book->student->student_name  
    

    Case 3 : Get subject name

    $book->subject->subject_name
    

    Case 4 : Get all the books within a subject

    $subjects = \App\Models\Subject::with('books')->get();
    

    Case 5 : Get all of a specific student`s books

    $students = \App\Models\Subject::with('students')->get();
    

    Angular 6 CRUD Operations Application Tutorials

    Read :

    Summary

    You can also read about AngularJS, ASP.NET, VueJs, PHP.

    I hope you get an idea about Laravel Tips Tricks and Techniques for Developers.
    I would like to have feedback on my Pakainfo.com blog.
    Your valuable feedback, question, or comments about this article are always welcome.
    If you enjoyed and liked this post, don’t forget to share.