Tagged: Laravel

Clear All Cache From Laravel project 5.7 0

Clear All Cache From Laravel project 5.7

Today, We want to share with you Clear All Cache From Laravel project 5.7.In this post we will show you How to clear config cache in Laravel using Artisan, hear for Laravel 5.7 clear cache from route, view, config and all cache data from application we will give you demo and example for implement.In this post, we will learn about Laravel Clear Cache – How to Clear Cache on Views, Config, Route, etc with an example.

Clear All Cache From Laravel project 5.7

There are the Following The simple About Clear All Cache From Laravel project 5.7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop Clear All Cache From Laravel project 5.7 in controller using route, so the laravel clear bootstrap cache Laravel Clear cache Tutorial With Example for this example is following below.

Laravel 5.7 Clear all cache Examples

laravel clear config cache Example with Laravel Clear Cache Commands

Clear Config cache using Laravel

php artisan config:cache

Laravel Clear View cache

php artisan view:clear

Clear Laravel Route cache:

php artisan route:cache

Clear Cache in Laravel facade value

php artisan cache:clear

Reoptimized class loader in Laravel

php artisan optimize

Laravel 5.7 Clear cache in shared hosting server

Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('cache:clear');
    // return what you want
});

We can check the Main Website official doc here http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

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 Clear All Cache From Laravel project 5.7.
I would like to have feedback on my Pakainfo.com blog for Clear All Cache From Laravel application 5.7.
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.

PHP Laravel Datatable Server Side Processing using jQuery 0

PHP Laravel Datatable Server Side Processing using jQuery Ajax

Today, We want to share with you PHP Laravel Datatable Server Side Processing using jQuery Ajax.In this post we will show you Datatables Server Side Processing in Laravel 5.7, hear for datatables Laravel server-side processing in codeigniter using ajax we will give you demo and example for implement.In this post, we will learn about jQuery Datatable Server Side Processing With Custom Operations using Laravel with an example.

PHP Laravel Datatable Server Side Processing using jQuery Ajax

There are the Following The simple About PHP Laravel Datatable Server Side Processing using jQuery Ajax Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel server side processing for Datatables, so the laravel 5.7 datatables package for this example is following below.

Step 1: include Datatables CSS file and Javascript files from CDN

<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<script type="text/javascript" language="javascript" src="http://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>

Step 2: HTML table in Laravel Blade File

Here are the steps to be followed for Implement datatables server side processing Laravel

Let the Laravel blade view page be datatable.blade.php. Your HTML Data table columns may be all the different but the step by step (laravel datatables tutorial) here.

<h3>List of The All Articles Title</h3>
<table class="table table-bordered" id="article_datatables">
    <thead>
           <th>Id</th>
           <th>Title</th>
           <th>Action</th>
          
    </thead>                
</table>

Step 3: javascript Source code

And then call simple Laravel Ajax using javascript source code given below. This ajax will automatically call action when you load your page.Below we can ajax request source code. Put this laravel datatables ajax source code to your Laravel blade view page of laravel at the bottom with laravel datatables pagination.

<script>
    $(document).ready(function () {
        $('#article_datatables').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax":{
                     "url": "/fetch_all_articles’",
                     "dataType": "json",
                     "type": "POST",
                     "data":{ _token: "{{csrf_token()}}"}
                   },
            "columns": [
                { "data": "id" },
                { "data": "title" },
                { "data": "action" }
            ]    

        });
    });
</script>

Step 4: Laravel Define Route

Put Laravel Route in your web.php files

And then we want set Laravel route for this method, so we have to go to routes/web.php file and write following source code for set route for index method.

Route::post(‘/fetch_all_articles’,’[email protected])

Step 5: Source code for fetchAllArticles function in ArticleController

jQuery Live Server side Datatable for pagination, records and search filters in laravel datatable server side.

 public function fetchAllArticles(Request $request)
    {

        $columns = array(
            0 => 'id',
            1 => 'title',
        );
        $totalTitles = Article::where('deleted_at', '=', null)
            ->count();
        $totalFiltered = $totalTitles;

        $limit = $request->input('length');
        $start = $request->input('start');
        $order = $columns[$request->input('order.0.column')];
        $page_dir = $request->input('order.0.dir');

        if (empty($request->input('search.value'))) {
            $titles = Article::where('deleted_at', '=', null)
                ->offset($start)
                ->limit($limit)
                ->orderBy($order, $page_dir)
                ->get();
        } else {
            $string_search = $request->input('search.value');

            $titles = Article::where('title', 'LIKE', "%{$string_search}%")
                ->where('deleted_at', '=', null)
                ->offset($start)
                ->limit($limit)
                ->orderBy($order, $page_dir)
                ->get();

            $totalFiltered = Article::where('title', 'LIKE', "%{$string_search}%")
                ->where('deleted_at', '=', null)
                ->count();
        }

        $all_products_data = array();
        if (!empty($titles)) {
            $count = 1;
            foreach ($titles as $title) {

                $nestedData['id'] = $count;
                $nestedData['title'] = $titles->title;
                $nestedData['action'] = '<button type="button" class="btn btn-success" onclick="" title="Edit">
                                        </button>
                                        <button type="button" style="margin-left:6px;" class="btn btn-success" onclick="" title="Article Delete">
                                        </button>';
                $all_products_data[] = $nestedData;
                $count++;
            }
        }

        $product_data = array(
            "draw" => intval($request->input('draw')),
            "recordsTotal" => intval($totalTitles),
            "recordsFiltered" => intval($totalFiltered),
            "data" => $all_products_data,
        );
        echo json_encode($product_data);
 }

Code Understanding

$request – In this case by default all datatables parameters are gets that are sent by jquery ajax serever side datatable.

$totalTitles – totalTitles are the sum all thr count that will be used for Ajax call jquery Datatables pagination in your Laravel Serverside datatable.

$limit – page data record limit is the set variable that init mode number of data records to be get at a time. ( No of total data records to display on page one )

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 Laravel Datatable Server Side Processing using jQuery Ajax.
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 AJAX Live Search Example 0

Laravel AJAX Live Search Example

Today, We want to share with you Laravel AJAX Live Search Example.In this post we will show you Laravel 5.6 – Dynamic Ajax Autocomplete Search Box, hear for Create Live Search In Laravel Using AJAX we will give you demo and example for implement.In this post, we will learn about Ajax Live Search Table Generation in Laravel with an example.

Laravel AJAX Live Search Example

There are the Following The simple About Laravel AJAX Live Search Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Typeahead Search Tutorial With Example, so the Fetch records from MySQL with jQuery AJAX – Laravel for this example is following below.

Define the Laravel Routes

<?php
Route::get('/live_search', '[email protected]');
Route::get('/live_search/action', '[email protected]')->name('live_search.action');
?>

Create a Laravel Blade file View

resources/views/live_search.blade.php

<!DOCTYPE html>
<html>
 <head>
  <title>Live search in laravel using AJAX - Pakainfo.com</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 </head>
 <body>
  <br />
  <div class="container box pakainfo">
   <h3 align="center">Live search in laravel using AJAX - Pakainfo.com</h3><br />
   <div class="panel panel-success pakainfo">
    <div class="panel-heading pakainfo">Search Member Data</div>
    <div class="panel-body pakainfo">
     <div class="form-group pakainfo">
      <input type="text" name="search" id="search" class="form-control" placeholder="Search Member Data" />
     </div>
     <div class="table-responsive pakainfo">
      <h3 align="center">Total Member Data : <span id="total_records"></span></h3>
      <table class="pakainfo table table-striped table-bordered">
       <thead>
        <tr>
         <th>Member Name</th>
         <th>RecAddress</th>
         <th>Country</th>
         <th>Postal Code</th>
         <th>Area</th>
        </tr>
       </thead>
       <tbody>

       </tbody>
      </table>
     </div>
    </div>    
   </div>
  </div>

  <script>
$(document).ready(function(){

 fetch_customer_data();

 function fetch_customer_data(query = '')
 {
  $.ajax({
   url:"{{ route('live_search.action') }}",
   method:'GET',
   data:{query:query},
   dataType:'json',
   success:function(data)
   {
    $('tbody').html(data.table_data);
    $('#total_records').text(data.total_data);
   }
  })
 }

 $(document).on('keyup', '#search', function(){
  var query = $(this).val();
  fetch_customer_data(query);
 });
});
</script>

 </body>
</html>

Create the Controller using PHP artisan

php artisan make:controller LiveSearch

Laravel Create Controller

app/Http/controller/LiveSearch.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;

class LiveSearch extends Controller
{
    function index()
    {
     return view('live_search');
    }

    function action(Request $request)
    {
     if($request->ajax())
     {
      $output = '';
      $query = $request->get('query');
      if($query != '')
      {
       $data = DB::table('tbl_customer')
         ->where('MemberName', 'like', '%'.$query.'%')
         ->orWhere('RecAddress', 'like', '%'.$query.'%')
         ->orWhere('Country', 'like', '%'.$query.'%')
         ->orWhere('ZipCode', 'like', '%'.$query.'%')
         ->orWhere('Area', 'like', '%'.$query.'%')
         ->orderBy('MemberId', 'desc')
         ->get();
         
      }
      else
      {
       $data = DB::table('tbl_customer')
         ->orderBy('MemberId', 'desc')
         ->get();
      }
      $total_row = $data->count();
      if($total_row > 0)
      {
       foreach($data as $datarow)
       {
        $output .= '
        <tr>
         <td>'.$datarow->MemberName.'</td>
         <td>'.$datarow->RecAddress.'</td>
         <td>'.$datarow->Country.'</td>
         <td>'.$datarow->ZipCode.'</td>
         <td>'.$datarow->Area.'</td>
        </tr>
        ';
       }
      }
      else
      {
       $output = '
       <tr>
        <td align="center" colspan="5">No Any Member Data Found</td>
       </tr>
       ';
      }
      $data = array(
       'table_data'  => $output,
       'total_data'  => $total_row
      );

      echo json_encode($data);
     }
    }
}

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 AJAX Live Search Example.
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.

PHP Laravel Inline CRUD Using jQuery and AJAX 0

PHP Laravel Inline CRUD Using jQuery and AJAX

Today, We want to share with you PHP Laravel Inline CRUD Using jQuery and AJAX.In this post we will show you Create Inline CRUD Using PHP, Laravel, jQuery and AJAX, hear for HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax we will give you demo and example for implement.In this post, we will learn about Inline Table Editing using jQuery Ajax Laravel and MySQL with an example.

PHP Laravel Inline CRUD Using jQuery and AJAX

There are the Following The simple About PHP Laravel Inline CRUD Using jQuery and AJAX Full Information With Example and source code.

As I will cover this Post with live Working example to develop jQuery AJAX Inline CRUD with PHP Laravel, so the jQuery AJAX Inline CRUD using PHP Laravel MySQL for this example is following below.

Phase 1 : Install Laravel Application

Simple HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax

Laravel 5.7 version application using bellow composer command

composer create-project --prefer-dist laravel/laravel system_project

Phase 2: MySQL .env files Database Configuration

database configuration in Laravel env files

.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=MyDBNAme
DB_USERNAME=DATABASE_USERNAME
DB_PASSWORD=MY_DATABASE_PASSWORD

Phase 3: Make a productlist Table and Model

make a Laravel migration for productlist table using Laravel 5.7

Table Name : productlist

php artisan make:migration create_productlist_table

database/migrations

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagslistTable extends Migration
{
    public function up()
    {
        Schema::create('productlist', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('productlist');
    }
}

run simple Laravel commands migration

Make a Laravel 5.7 migration and Model

php artisan migrate

php artisan make:model ProductList

app/ProductList.php

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ProductList extends Model
{
    public $table = "productlist";
    public $fillable = ['name'];
}

Phase 4: Define Laravel Routes

routes/web.php

Route::get("multipleInptFrm","[email protected]");
Route::post("multipleInptFrm","[email protected]");

Phase 5: Create ProductController

create new controller as ProductController

php artisan make:controller ProductController

app/Http/Controllers/ProductController.php

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\ProductList;
use Validator;

class ProductController extends Controller
{
    public function moreAddData()
    {
        return view("moreAddData");
    }
    public function moreAddDataPost(Request $request)
    {
        $rules = [];
        foreach($request->input('name') as $key => $value) {
            $rules["name.{$key}"] = 'required';
        }

        $validator = Validator::make($request->all(), $rules);
        if ($validator->passes()) {

            foreach($request->input('name') as $key => $value) {
                ProductList::create(['name'=>$value]);
            }

            return response()->json(['success'=>'done']);
        }
        return response()->json(['error'=>$validator->errors()->all()]);
    }
}

Phase 6: Make a Laravel Blade File

resources/views/moreAddData.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Inline Table Editing using jQuery Ajax Laravel and MySQL - Pakainfo.com</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  

 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
    <meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>


<div class="container">
    <h2 align="center">Laravel - HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax</h2>  
    <div class="form-group">
         <form name="product_name_add" id="product_name_add">  


            <div class="alert alert-danger message-errors-display" style="display:none">
            <ul></ul>
            </div>


            <div class="alert alert-success message-display" style="display:none">
            <ul></ul>
            </div>


            <div class="table-responsive">  
                <table class="table table-bordered" id="dynamic_field">  
                    <tr>  
                        <td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" /></td>  
                        <td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>  
                    </tr>  
                </table>  
                <input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />  
            </div>


         </form>  
    </div> 
</div>


<script type="text/javascript">
    $(document).ready(function(){      
      var postURL = "<?php echo url('multipleInptFrm'); ?>";
      var i=1;  


      $('#add').click(function(){  
           i++;  
           $('#dynamic_field').append('<tr id="row'+i+'" class="dynamic-added"><td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" /></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');  
      });  


      $(document).on('click', '.btn_remove', function(){  
           var button_id = $(this).attr("id");   
           $('#row'+button_id+'').remove();  
      });  


      $.ajaxSetup({
          headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
      });


      $('#submit').click(function(){            
           $.ajax({  
                url:postURL,  
                method:"POST",  
                data:$('#product_name_add').serialize(),
                type:'json',
                success:function(data)  
                {
                    if(data.error){
                        displayMessageError(data.error);
                    }else{
                        i=1;
                        $('.dynamic-added').remove();
                        $('#product_name_add')[0].reset();
                        $(".message-display").find("ul").html('');
                        $(".message-display").css('display','block');
                        $(".message-errors-display").css('display','none');
                        $(".message-display").find("ul").append('<li>Record Inserted Successfully.</li>');
                    }
                }  
           });  
      });  


      function displayMessageError (msg) {
         $(".message-errors-display").find("ul").html('');
         $(".message-errors-display").css('display','block');
         $(".message-display").css('display','none');
         $.each( msg, function( key, value ) {
            $(".message-errors-display").find("ul").append('<li>'+value+'</li>');
         });
      }
    });  
</script>
</body>
</html>

run command

php artisan serve

// open bellow URL
http://localhost:8000/multipleInptFrm

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 Laravel Inline CRUD Using jQuery and AJAX.
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.

How to get last record from MySQL table in Laravel? 0

How to get last record from MySQL table in Laravel

Today, We want to share with you How to get last record from MySQL table in Laravel?.In this post we will show you Get latest row of table in model, hear for How to get last record of database table in Laravel? we will give you demo and example for implement.In this post, we will learn about How to get last record from table in PHP Laravel Framework with an example.

How to get last record from MySQL table in Laravel?

There are the Following The simple About How to get last record from MySQL table in Laravel? Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel – Select Last Row in the Table, so the some Select Last Row in the Table for this example is following below.

Using latest() belong to created_at field: Laravel

$products = DB::table('products')->latest()->first();
dd($products);

Using orderBy() belong to id field: Laravel

$products2 = DB::table('products')->orderBy('id', 'DESC')->first();
dd($products2);

Using latest() in Laravel belong to id field:

$products3 = DB::table('products')->latest('id')->first();
dd($products3);

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 How to get last record from MySQL table in Laravel?.
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.

Ajax Dynamic Dependent Dropdown using Laravel Example 0

Ajax Dynamic Dependent Dropdown using Laravel Example

Today, We want to share with you Ajax Dynamic Dependent Dropdown using Laravel Example.In this post we will show you country state city drop down list using ajax in laravel, hear for Dependent Select Box for Laravel Beginners we will give you demo and example for implement.In this post, we will learn about laravel, jquery ajax categories and subcategories, select dropdown with an example.

Ajax Dynamic Dependent Dropdown using Laravel Example

There are the Following The simple About Ajax Dynamic Dependent Dropdown using Laravel Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to show selected value in dropdown in laravel 5.7, so the country state city drop down list in laravel 5.7 for this example is following below.

Step 1: Create Laravel Model

php artisan make:model Model\MyState 
php artisan make:model Model\MyCity

App/Http/Model/MyState.php

<?php 
namespace App\Model; 
use Illuminate\Database\Eloquent\Model; 
class MyState extends Model 
{ 
	// Your Logic
}

App/Http/Model/MyCity.php

<?php 
namespace App\Model\Demo\live_drop_down; 
use Illuminate\Database\Eloquent\Model; 
class MyCity extends Model 
{ 
	// Your Logic
}

Step 2: Create Laravel Controller

DependentDropdownController.php

    <?php
    namespace App\Http\Controllers\Demo\live_drop_down;
    use App\Http\Controllers\Controller;
    use App\Model\Demo\live_drop_down\MyCity;
    use App\Model\Demo\live_drop_down\MyState;
    use Illuminate\Http\Request;
    class DependentDropdownController extends Controller
    {
        /**
         * Display a listing of the resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function index()
        {
            $name_states = MyState::all();
            return view('demo.live_drop_down.index',compact('name_states'));
        }
        public function destroy($id)
        {
            //
        }
        public function searchYourCity($id)
        {
            $name_city = MyCity::where('name_state_id',$id)->get();
            return response()->json($name_city);
        }
    }

Step 3: Define a Laravel Route

    Route::get('searchYourCity/{id}','Demo\live_drop_down\[email protected]');

Step 4: Make Laravel Blade View

resource/view/dropdown

    @extends('master.app')
    @section('main-content')
    <div class="col-md-8 col-md-offset-2">
      <div class="panel panel-success">
          <div class="panel-heading">
			<h3>How To Create Dependent Drop down in Laravel</h3>
          </div>
          <div class="pakainfo panel-body">
        <form action="{{ route('dynamic-dropdown-laravel.store') }}" method="post">
         {{ csrf_field() }}
         <div class="pakainfo row">
          <div class="pakainfo col-md-6">
           <div class="pakainfo form-group {{ ($errors->has('roll'))?'has-error':'' }}">
            <label for="roll">MyState <span class="required">*</span></label>
            <select name="name_state" class="pakainfo form-control" id="name_state">
             <option value="">-- Select MyState --</option>
             @foreach ($name_states as $name_state)
              <option value="{{ $name_state->id }}">{{ ucfirst($name_state->name_state_name) }}</option>
             @endforeach
            </select>
         </div>
          </div>
          <div class="col-md-6">
           <div class="form-group {{ ($errors->has('name'))?'has-error':'' }}">
            <label for="roll">MyCity </label>
            <select name="name_city" class="form-control" id="name_city">
            </select>
         </div>
          </div>
         </div>
       </form> 
	   <a href="https://pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
          </div>
        </div>
    </div>
        
    @endsection

Step 5: Create jQuery Ajax

    @section('script')
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script type="text/javascript" src="{{ asset('assets/js/jquery-3.3.1.min.js') }}"></script>
        <script type="text/javascript" src="{{ asset('assets/js/bootstrap.min.js') }}"></script>
     <script>
             $(document).ready(function() {
            $('#name_state').on('change', function() {
                var getStId = $(this).val();
                if(getStId) {
                    $.ajax({
                        url: '/searchYourCity/'+getStId,
                        type: "GET",
                        data : {"_token":"{{ csrf_token() }}"},
                        dataType: "json",
                        success:function(data) {
                            //console.log(data);
                          if(data){
                            $('#name_city').empty();
                            $('#name_city').focus;
                            $('#name_city').append('<option value="">-- Select MyCity --</option>'); 
                            $.each(data, function(key, value){
                            $('select[name="name_city"]').append('<option value="'+ key +'">' + value.name_city_name+ '</option>');
                        });
                      }else{
                        $('#name_city').empty();
                      }
                      }
                    });
                }else{
                  $('#name_city').empty();
                }
            });
        });
        </script>

Angular 6 CRUD Operations Application Tutorials

Related Search: Dependent Select Box for Laravel Beginners, Ajax Dynamic Dependent Dropdown in Laravel, Laravel Dependent Dropdown, dynamic dropdown in laravel, laravel ajax dropdown, laravel, jquery ajax categories and subcategories, select dropdown, select2 dependent dropdown laravel, dependent drop down list using jquery, country state city drop down list in laravel, country state city drop down list using ajax in laravel, how to show selected value in dropdown in laravel 5

Read :

Summary

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

I hope you get an idea about Ajax Dynamic Dependent Dropdown using Laravel Example.
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.

MySQL Full Text Search Laravel Tutorial With Example 0

MySQL Full Text Search Laravel Tutorial With Example

Today, We want to share with you MySQL Full Text Search Laravel Tutorial With Example.In this post we will show you Indexed full text search in Laravel MySQL, hear for Laravel Full-Text Search Engine using MySQL we will give you demo and example for implement.In this post, we will learn about How to Search in MySQL using full-text indexing in Laravel with an example.

MySQL Full Text Search Laravel Tutorial With Example

There are the Following The simple About MySQL Full Text Search Laravel Tutorial With Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop MySQL Full text search in Laravel Example, so the MySQL Full-Text Search PHP Tutorial for this example is following below.

Step 1: Laravel Project Package Installation

Simple execute the below Laravel command in your CMD.

composer require nicolaslopezj/searchable

Step 2: Laravel Package Setup

app/Member.php

<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\Member as Authenticatable;
use Nicolaslopezj\Searchable\SearchableTrait;
class Member extends Authenticatable
{
    use Notifiable;
    use SearchableTrait;
    protected $searchable = [
        'columns' => [
            'members.name' => 10,
            'members.email' => 5,
            'members.id' => 3,
        ]
    ];

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
}

Step 3: Define a Laravel Route

routes/web.php

Route::get("live-member-search","[email protected]");

Step 4: Create a Laravel Controller

app/Http/Controllers/MemberController.php

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Member;
class MemberController extends Controller
{
    public function memberSearch(Request $request)
    {
    	if($request->has('search')){
    		$members = Member::search($request->get('search'))->get();	
    	}else{
    		$members = Member::get();
    	}
    	return view('live-member-search', compact('members'));
    }
}

Step 5: Make a Laravel Blade View File

resources/views/live-member-search.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>MySQL Full text search in Laravel Example - pakainfo.com</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
</head>


<body>
  <div class="container">
    <h1>MySQL Full text search in Laravel Example</h1>


    <form method="GET" action="{{ url('live-member-search') }}">
      <div class="pakainfo row">
        <div class="pakainfo col-md-6">
          <input type="text" name="search" class="pakainfo form-control" placeholder="Member Live Search" value="{{ old('search') }}">
        </div>
        <div class="col-md-6">
          <button class="btn btn-success">Member Search</button>
        </div>
      </div>
    </form>

	<h3>List of The Members</h3>
    <table class="table table-bordered">
      <tr>
        <th>Id</th>
        <th>Member Name</th>
        <th>Member Email</th>
      </tr>
      @if($members->count())
        @foreach($members as $member)
        <tr>
          <td>{{ $member->id }}</td>
          <td>{{ $member->name }}</td>
          <td>{{ $member->email }}</td>
        </tr>
        @endforeach
      @else
      <tr>
        <td colspan="3">Data not found.</td>
      </tr>
      @endif
    </table>

  </div>
</body>
</html>

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 MySQL Full Text Search Laravel Tutorial With Example.
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.