Topic: Laravel

Bootstrap Toggle Inside JQuery DataTable 0

Bootstrap Toggle Inside JQuery DataTable

Today, We want to share with you Bootstrap Toggle Inside JQuery DataTable.In this post we will show you Bootstrap Switch / Toggle – examples, hear for bootstrap 4 toggle switch jQuery DataTables we will give you demo and example for implement.In this post, we will learn about How To Display Bootstrap Toggle Switch with DataTables via Render with an example.

Bootstrap Toggle Inside JQuery DataTable

There are the Following The simple About Bootstrap Toggle Inside JQuery DataTable Full Information With Example and source code.

Laravel Bootstrap Toggle switch Update DB field using Ajax

As I will cover this Post with live Working example to develop jQuery Datatable toggle filter, so the some major files and Directory structures for this example

Toggle Switches Laravel, Ajax and jQuery example

is following below.

DataTable Bootstrap Toggle

 <table id="saved-members-table" class="display responsive nowrap table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr><th><?php echo $global['client_name'];?></th> 
     <th><?php echo $global['phone'];?></th>
     <th>PC. No</th>
     <th>Membership Type</th>
     <th>Status</th>
 </tr>
</thead>
</table>

Laravel Toggle Switch Inside Bootstrap Ajax Example

HTML Part

<input id="live-toggle-example" type="checkbox" checked data-toggle="toggle" data-on="Active" data-off="Due" data-onstyle="success" data-offstyle="warning">

jQuery('#live-toggle-example').bootstrapToggle();

Laravel 5.7 Toggle switch Update DB field using Ajax

And then, the jQuery DataTable Server-side Processing JS source Code.

jQuery('#saved-members-table').DataTable({
    "processing": true,
    "serverSide": true,
    "ajax": "pakacodes.php?Members=yes", 
     "sScrollX": "100%", 
    aoColumns : [                          
        { "sWidth": "20%" },
        { "sWidth": "20%"},
        { "sWidth": "20%"},
        { "sWidth": "20%"},                           
        { "sWidth": "20%" }
    ],
"fnDrawCallback": function() {
    jQuery('#saved-members-table #live-toggle-example').bootstrapToggle();
}

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 Bootstrap Toggle Inside JQuery DataTable.
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 Redirect Tutorial Example From Scratch 0

Laravel Redirect Tutorial Example From Scratch

Today, We want to share with you Laravel Redirect Tutorial Example From Scratch.In this post we will show you Laravel 5.7 Redirect Based On Referrer Or IP Address, hear for Laravel Redirect To Another URL / Web Page Script Example we will give you demo and example for implement.In this post, we will learn about Laravel Redirect to URL After Form Submission with an example.

Laravel Redirect Tutorial Example From Scratch

There are the Following The simple About Laravel Redirect Tutorial Example From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to redirect from one page to another in Laravel 5.7, so the HTTP Redirects Laravel for this example is following below.

Simple Laravel Page Redirect

return redirect('homepage');

Redirects to https://www.pakainfo.com/homepage

return redirect('auth/login');

Redirects to www.pakainfo.com/auth/login

return redirect('');

Redirects to the main page – www.pakainfo.com

Chaining Methods and Redirecting Back

laravel redirect to previous page

return redirect()->back();

Laravel Redirect with Data

return redirect()->back()->with('error', 'Sorry, Something went wrong contact us(Pakainfo.com).');

Reminder: Session Flash Data

laravel redirect with success/Error message and laravel redirect with variable

//laravel redirect with post data
return redirect()->back()->with('error', 'Something went wrong.')->with('order_value', $value);

//use arrays
$parameters = ['error' => 'Something went wrong.', 'order_value' => $value];
return redirect()->back()->with($parameters);

using withInput()
return redirect()->back()->withInput();

Laravel Redirect to a Route

app/Http/routes.php

laravel redirect with data array using Route

get('products', ['as' => 'products_list', 'uses' => '[email protected]']);

app/Http/Controllers/ProductController.php

return redirect()->route('products');

app/Http/routes.php:

get('product/{id}', ['as' => 'product_view', 'uses' => '[email protected]']);

app/Http/Controllers/ProductController.php

return redirect()->route('product_view', 1);

app/Http/routes.php:

get('product/{category}/{id}', ['as' => 'product_view', 'uses' => '[email protected]']);

app/Http/Controllers/ProductController.php

return redirect()->route('product_view', [692, 1]);

//with parameters
return redirect()->route('product_view', ['category'=>692, 'id'=>1]);

Laravel Redirect to a Controller Action

return redirect()->action('App\Http\Controllers\[email protected]');

//with arguments
return redirect()->action('App\Http\Controllers\[email protected]', [1]);

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 Redirect Tutorial Example From Scratch.
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 5.7 Jquery Ajax CRUD(insert update delete) 0

Laravel 5.7 Jquery Ajax CRUD(insert update delete)

Today, We want to share with you Laravel 5.7 Jquery Ajax CRUD(insert update delete).In this post we will show you Ajax CRUD example in Laravel 5.7 application, hear for Laravel 5.7 CRUD (Create Read Update Delete) Example from scratch we will give you demo and example for implement.In this post, we will learn about Laravel 5.7 CRUD Insert Update Delete using Jquery Ajax Tutorial example with source code with an example.

Laravel 5.7 Jquery Ajax CRUD(insert update delete)

There are the Following The simple About Laravel 5.7 Jquery Ajax CRUD(insert update delete) Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 CRUD (Create Read Update Delete) Tutorial Example, so the Simple Laravel 5.7 Jquery Ajax CRUD(insert update delete) tutorial example with source code for this example is following below.

Step : 1 Create articles Table Migration

Laravel Table Migration

php artisan make:migration create_Articles_table

After run this commandd open articles table mimgration file and add foollowing code. migration file create automatic in database/migrations/ this location.

database/migrations/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('article_content');
            $table->timestamps();
        });
    }

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

And then, Laravel CMD to run following command for run migration.

php artisan migrate

Step : 2 Create articles Table Model

After that, create Article table model usign by following command.

php artisan make:demo Article

And then, open app/Article.php file and past into it following source code.

app/Article.php

namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    protected $fillable = [
        'title', 'article_content'
    ];
}

Step : 3 Create Laravel Routes

Next, create following routes in routes/web.php file.

routes/web.php

Route::get('web-articles', '[email protected]');
Route::resource('articles','ArticleController');

Step : 4 Make Laravel 5.7 Controller

And then, we need to create ArticleController.php file in app/Http/Controllers/ this path and put into it following source code.

app/Http/Controllers/ArticleController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Article;

class ArticleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function webArticles()
    {
        return view('web-articles');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $articles = Article::latest()->paginate(5);
        return response()->json($articles);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $Article = Article::create($request->all());
        return response()->json($Article);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $Article = Article::find($id)->update($request->all());
        return response()->json($Article);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        Article::find($id)->delete();
        return response()->json(['done']);
    }
}

Step : 5 Create Laravel Blade/View File

Now, we will make a web-articles.blade.php file in resources/views/ folder. and then simply put into it following source code. here We are using simple bootstrap layout but you can set accourding to you.

resources/views/web-articles.blade.php

<!DOCTYPE html>
<html>
<head>
  <title>Laravel 5.7 Ajax CRUD Example</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css">
</head>
<body>
  <div class="container">
    <div class="row">
        <div class="col-lg-12 margin-tb">
            <div class="pull-left">
                <h2>Laravel 5.7 Ajax CRUD Example Demo</h2>
            </div>
            <div class="pull-right">
        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-data-component">Create New Article</button>
            </div>
        </div>
    </div>
    <table class="table table-bordered">
      <thead>
          <tr>
        <th>Title</th>
        <th>article_content</th>
        <th width="200px">Action</th>
          </tr>
      </thead>
      <tbody>
      </tbody>
    </table>

    <ul id="pagination" class="pagination-sm"></ul>

    <!-- Create data-component Modal -->
    @include('create')
    <!-- Edit data-component Modal -->
    @include('edit')
  </div>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twbs-pagination/1.3.1/jquery.twbsPagination.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"></script>
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">

  <script type="text/javascript">
    var url = "<?php echo route('articles.index')?>";
  </script>
  <script src="/js/ArticlesAjax.js"></script> 
</body>
</html>

Step : 6 Create JS File

Next, we need to create ArticlesAjax.js JS file in public/js/ path and put into it following source code.

public/js/ArticlesAjax.js

var page = 1;
var active_page = 1;
var total_page = 0;
var ajax_data_call = 0;

manageData();

/* manage data list */
function manageData() {
    $.ajax({
        dataType: 'json',
        url: url,
        data: {page:page}
    }).done(function(data) {
      total_page = data.last_page;
      active_page = data.active_page;
      $('#pagination').twbsPagination({
          totalPages: total_page,
          visiblePages: active_page,
          onPageClick: function (event, pageL) {
            page = pageL;
                if(ajax_data_call != 0){
              fetchAllData();
                }
          }
      });
      handleDatalines(data.data);
        ajax_data_call = 1;
    });
}

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

/* Get Page Data*/
function fetchAllData() {
  $.ajax({
      dataType: 'json',
      url: url,
      data: {page:page}
  }).done(function(data) {
    handleDatalines(data.data);
  });
}

/* Add new Article table row */
function handleDatalines(data) {
  var data_lines = '';
  $.each( data, function( key, value ) {
      data_lines = data_lines + '<tr>';
      data_lines = data_lines + '<td>'+value.title+'</td>';
      data_lines = data_lines + '<td>'+value.article_content+'</td>';
      data_lines = data_lines + '<td data-id="'+value.id+'">';
        data_lines = data_lines + '<button data-toggle="modal" data-target="#edit-data-component" class="btn btn-primary edit-data-component">Edit</button> ';
        data_lines = data_lines + '<button class="btn btn-danger remove-data-component">Delete</button>';
        data_lines = data_lines + '</td>';
      data_lines = data_lines + '</tr>';
  });
  $("tbody").html(data_lines);
}

/* Create new Article */
$(".crud-submit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#create-data-component").find("form").attr("action");
    var title = $("#create-data-component").find("input[name='title']").val();
    var article_content = $("#create-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'Article',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Created Successfully.', 'Success Alert', {timeOut: 5000});
    });
});

/* Remove Article */
$("body").on("click",".remove-data-component",function() {
    var id = $(this).parent("td").data('id');
    var c_obj = $(this).parents("tr");
    $.ajax({
        dataType: 'json',
        type:'delete',
        url: url + '/' + id,
    }).done(function(data) {
        c_obj.remove();
        toastr.success('Article Deleted Successfully.', 'Success Alert', {timeOut: 5000});
        fetchAllData();
    });
});

/* Edit Article */
$("body").on("click",".edit-data-component",function() {
    var id = $(this).parent("td").data('id');
    var title = $(this).parent("td").prev("td").prev("td").text();
    var article_content = $(this).parent("td").prev("td").text();
    $("#edit-data-component").find("input[name='title']").val(title);
    $("#edit-data-component").find("textarea[name='article_content']").val(article_content);
    $("#edit-data-component").find("form").attr("action",url + '/' + id);
});

/* Updated new Article */
$(".crud-submit-edit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#edit-data-component").find("form").attr("action");
    var title = $("#edit-data-component").find("input[name='title']").val();
    var article_content = $("#edit-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'PUT',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Updated Successfully.', 'Success Alert', {timeOut: 5000});
    });
}); 

Last I am ready to Laravel Project run our example Therefor run bellow command ro quick run:

Laravel 5.7 run our example

php artisan serve

Finnally Step We can open bellow simple URL on your Browsers run:

http://localhost:8000/web-articles

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 5.7 Jquery Ajax CRUD(insert update delete).
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 GET POST PUT DELETE Methods 0

Laravel GET POST PUT DELETE Methods

Today, We want to share with you Laravel GET POST PUT DELETE Methods.In this post we will show you Laravel 5.7 Guzzle http client POST request example, hear for cURL Request in Laravel Guzzle http client GET and POST Examples we will give you demo and example for implement.In this post, we will learn about Guzzle http client GET and POST request example in Laravel 5.7 with an example.

Laravel GET POST PUT DELETE Methods

There are the Following The simple About Laravel GET POST PUT DELETE Methods Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Guzzle http client example, so the HTTP GET and POST Methods in PHP for this example is following below.

Requests Using Guzzle:

Laravel Install guzzlehttp/guzzle package

Let’s start we shall simple step by step install guzzlehttp/guzzle Laravel packageb> after that we can best way to use all the CRUD method Therefor Simple Laravel run bellow command.

composer require guzzlehttp/guzzle:~6.0

Now here We will step by step display you how to HTTP POST Using Laravel CURL run all GET, POST, PUT and DELETE in Laravel listed request you can use following Laravel 5.7 controller method:

Laravel Guzzle http client example Get Request:

public function getAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $api_curl_req = $curl_api_clients->get('https://pakainfo.com');
    $api_results = $api_curl_req->getBody();
    dd($api_results);
}

Laravel 5.7 Guzzle http Post Request:

public function postAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts";
    $param_body_data['name'] = "Paka Information";
    $api_curl_req = $curl_api_clients->post($url,  ['body'=>$param_body_data]);
    $api_results = $api_curl_req->send();
    dd($api_results);

}

Execute a HTTP Put Request in Laravel:

public function putAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts/1";
    $param_body_data['name'] = "Laravel 5.7 Examples";
    $api_curl_req = $curl_api_clients->put($url,  ['body'=>$param_body_data]);
    $api_results = $api_curl_req->send();
    dd($api_results);
}

Guzzle http Delete Request Example:

public function deleteAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts/1";
    $api_curl_req = $curl_api_clients->delete($url);
    $api_results = $api_curl_req->send();
    dd($api_results);

}

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 GET POST PUT DELETE Methods.
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 CURL HTTP GET POST Request 0

Today, We want to share with you PHP Laravel CURL HTTP GET POST Request.In this post we will show you php Laravel 5.7 curl get request with parameters example, hear for Laravel cURL GET request and request’s body we will give you demo and example for implement.In this post, we will learn about CURL API CALLS WITH Laravel AND JSON DATA (GET POST PUT DELETE) with an example.

PHP Laravel CURL HTTP GET POST Request

There are the Following The simple About PHP Laravel CURL HTTP GET POST Request Full Information With Example and source code.

As I will cover this Post with live Working example to develop php curl get request with parameters, so the curl put request php Laravel 5.7 for this example is following below.

PHP CURL POST & GET Examples

Laravel CURL HTTP GET Request

$php_curl = curl_init();

curl_setopt_array($php_curl, array(
    CURLOPT_URL => "https://pakainfo.com",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_TIMEOUT => 30000,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
      // Set Here Your Laravel curl Requesred Headers
        'Content-Type: application/json',
    ),
));
$final_results = curl_exec($php_curl);
$err = curl_error($php_curl);
curl_close($php_curl);

if ($err) {
    echo "Laravel cURL Error #:" . $err;
} else {
    print_r(json_decode($final_results));
}
 

Laravel CURL HTTP POST Request

Laravel 5.7 Make POST Request Examples(curl in Laravel POST Request)

// Make Post Fields Array
$products_data = [
    'product_name' => 'Laravel Curl Example Books',
    'product_desc' => 'Laravel 5.7 - How To Make cURL HTTP Request Example',
];

$php_curl = curl_init();

curl_setopt_array($php_curl, array(
    CURLOPT_URL => "https://pakainfo.com",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30000,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => json_encode($products_data),
    CURLOPT_HTTPHEADER => array(
      // Set POST here requred headers
        "accept: */*",
        "accept-language: en-US,en;q=0.8",
        "content-type: application/json",
    ),
));

$final_results = curl_exec($php_curl);
$err = curl_error($php_curl);

curl_close($php_curl);

if ($err) {
    echo "Laravel cURL Error #:" . $err;
} else {
    print_r(json_decode($final_results));
}

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 CURL HTTP GET POST Request.
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 Combine multiple queries Tutorials 0

Laravel Combine multiple queries

Today, We want to share with you Laravel Combine multiple queries.In this post we will show you Merging two complex Eloquent queries, hear for Laravel merge two query result into single object we will give you demo and example for implement.In this post, we will learn about Combining result tables from multiple SELECT statements with an example.

Laravel Combine multiple queries

There are the Following The simple About Laravel Combine multiple queries Full Information With Example and source code.

As I will cover this Post with live Working example to develop multiple tables with one query with Laravel 5.7, so the Laravel 5.7 inner join with multiple conditions example using Query Builder for this example is following below.

Combine multiple queries (Laravel 5.7)

Laravel how merge two query result into single object

$student_match = Ladder::getTeamPosition($request->student_teach_id, $request->id)->get();
$teamStatistics = TeamCompetitionStatistics::getTeamStats($request->student_teach_id, $request->id)->get();

$merged = $teamStatistics->merge($student_match);
$result = $merged->all();

// return [{'student_match': 'data', 'student_match_details': 'data'}]

Combine two DB query results in Laravel

get all Student subjects

$studentSubjects= FilmSubjects::all();

get all new media subjects

$newMediaSubjectss=  NewMediaSubjects::all();

merge subjects

foreach($studentSubjects as $filmSubjects) {
    $newMediaSubjectss->add($filmSubjects);
}

or we can also do this

$newMediaSubjectss->toBase()->merge($studentSubjects);[]
 
dd($newMediaSubjectss->toArray());

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 Combine multiple queries.
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.

Update multiple records using Laravel 0

Update multiple records using Laravel

Today, We want to share with you Update multiple records using Laravel.In this post we will show you laravel update multiple rows with different values, hear for rails update multiple records with different values we will give you demo and example for implement.In this post, we will learn about Updating Multiple Records using Eloquent (Laravel 5.7) with an example.

Update multiple records using Laravel

There are the Following The simple About Update multiple records using Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel eloquent update array, so the delete multiple records using checkbox in Laravel for this example is following below.

Laravel Update & Delete multiple Records

public function removeAll(Request $request)
{
    $product_ids = $request->product_ids;
    DB::table("products")->whereIn('id',explode(",",$product_ids))->delete();
    return response()->json(['success'=>"Products Deleted successfully."]);
}

Laravel Delete Multiple Records Using Eloquent

Route::get('/', function () {

    $data = DB::table('products')->get();
    return view('form',['data'=>$data]);
});

Delete multiple records using Eloquent

Route::post('bulk-delete',function(Request $request) {

    $all_product_data = $request->except('_token');

    foreach($all_product_data as $id) {
        tbl_data::where('id',$id)->delete();
    }
    return redirect()->back();

});

Laravel delete multiple rows

$product_ids = array(25, 28, 30);
DB::table('products')->whereIn('id', $product_ids)->delete(); 

Using Laravel model We can also some perform mass MySQL deletion as below

$deleted_Rows = Users::where('id', '>', 500)->delete();
dd($deleted_Rows);

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 Update multiple records using 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.

laravel ajax csrf tokens Example jQuery Ajax Call 0

laravel ajax csrf tokens Example - jQuery Ajax Call

Today, We want to share with you laravel ajax csrf tokens Example.In this post we will show you csrf token laravel form, hear for Laravel 5 csrf tokens in ajax calls we will give you demo and example for implement.In this post, we will learn about CSRF Protection with Ajax and Laravel with an example.

laravel ajax csrf tokens Example

There are the Following The simple About laravel ajax csrf tokens Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop get csrf token in controller laravel, so the some major files and Directory structures for this example is following below.Laravel 5 csrf tokens in ajax calls

Pass the token in your Ajax headers

laravel ajax csrf, CSRF stands for simple meanning “cross site request forgery” as well as is a type of more some attack where as like a malicious website or any email, some instant message, as well as some program causes a web browser like a mozila, chrome to perform an unwanted some events action on a more website for which the get user is currently users authenticated.

$.ajaxSetup({ headers: { 'csrftoken' : '{{ csrf_token() }}' } });

In Laravel 5 version or any more Like Laravel 5.4, Laravel 5.5, Laravel 5.6, or Laravel 5.7, all laravel csrf token ajax requests must pass through server request the Middleware which will not allow any some json or any object POST requests without the correct(CSRF Protection) CSRF token.

CSRF (Cross Site Request Forgery)

Now, csrf token laravel ajax simple prevents the web site fetching requests from browser side means clients that it has not any types of the established a data connection with. IE a simple defination of the random post request from a any third party.

Example 1: laravel ajax post csrf

$.ajax({
  type: "POST",
  url: "/userinfoStatus",
  data: {   lastname: datalastname,
			firstresults: getfirstresults,
			bearing: 90,
			'_token': '{!! csrf_token() !!}'
		}
})

Example 2: laravel csrf token ajax

   
      <title>csrf token laravel ajax - Ajax Example</title>
      
      
      
      
      
         function getMessage() {
            $.ajax({
               type:'POST',
               url:'/userinfoStatus',
               data:'_token = ',
               success:function(data) {
                  $("#results").html(data.results);
               }
            });
         }
      
   
   
   
      <div id='results'>This message(laravel csrf token ajax) will be replaced using Ajax. 
         Click the button to Append the message.</div>
      'getMessage()']);
      ?>
   


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 csrf tokens 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.

Toggle Switches Laravel, Ajax and jQuery example 0

Toggle Switches Laravel, Ajax and jQuery example

Today, We want to share with you Toggle Switches Laravel, Ajax and jQuery example.In this post we will show you Multiple JQuery Toggle Buttons with on off events in Laravel 5.7, hear for store value from on/off button in mysql database using Laravel ajax we will give you demo and example for implement.In this post, we will learn about JQuery/AJAX Toggle Switch POST to Laravel file without navigation with an example.

Toggle Switches Laravel, Ajax and jQuery example

There are the Following The simple About Toggle Switches Laravel, Ajax and jQuery example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Create Radio Button Toggle Switch with Bootstrap and Laravel, so the Bootstrap Toggle switch with ajax update to mysql in Laravel 5.7 for this example is following below.

Laravel switchClass and toggleClass in jQuery

HTML Part for store value from on/off button in mysql database using Laravel ajax

<input type="checkbox" name="live_response" checked>
$("[name='live_response']").bootstrapSwitch('state');

JavaScript Source Code

$("[name='live_response']").bootstrapSwitch();
$(document).ready(function() {
    $("[name='live_response']").on('switchChange.bootstrapSwitch',function(){
        var mode_value = $(this).attr("value");
        var station = $(this).attr("id");
        $.ajax({
            url: 'statusUpdate',
            method: 'post',
            data: {id: mode_value, _token: $('input[name="_token"]').val(), reply_flag: mode_value, station: station},
            success: function(data){
                alert("Auto Canneded Response has been Turned On");
            },
            error: function(){}
        });
    });
});

Laravel Controller method

public function statusUpdate()
    {
        $data = Input::all();

        if(Request::ajax())
        {
            $station = Input::get('station');
            $live_response = AutoReply::where('station', $station)->all();
            $live_response->reply_flag = $data['reply_flag'];
            $live_response->update();
        }
    }

Example 2: Laravel Bootstrap Toggle switch

Laravel Bootstrap Toggle switch Update DB field using Ajax

Example 3: Laravel 5.7 Toggle switch

Laravel 5.7 Toggle switch Update DB field using Ajax

Example 4: Toggle Switch Inside Bootstrap Laravel

Laravel Toggle Switch Inside Bootstrap Ajax Example

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 Toggle Switches Laravel, Ajax and jQuery 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.

Laravel Database Eloquent Unions Query 0

Laravel Database Eloquent Unions Query

Today, We want to share with you Laravel Database Eloquent Unions Query.In this post we will show you laravel 5.7 union query, hear for laravel eloquent union query we will give you demo and example for implement.In this post, we will learn about union in laravel, union in laravel eloquent with an example.

Laravel Database Eloquent Unions Query

There are the Following The simple About Laravel Database Eloquent Unions Query Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel query builder union all, so the some Laravel Database Unions for this example is following below.

Example 1: Laravel Database Unions

The PHP Based Laravel Database Unions is used to combine the two MySQL Tables(laravel query builder union all) in the database.

$first = DB::table('members')
->whereNull('first_name');

$members = DB::table('members')
->whereNull('last_name')
->union($first)
->get();

Example 2: Laravel Eloquent Union query

Simple “merge” function in Laravel collection Eloquent

$a = Model::where('code', '=', $code)
->where('col_a', '=' , 1)
->orderBy(DB::raw('FIELD(member_name, "phone", "color", "address", "ip-faced", "") ASC, member_name'))->get();

$b = Model::where('code', '=', $code)
->where('col_b', '=' , 1)
->orderBy(DB::raw('FIELD(member_name, "phone", "color", "address", "ip-faced", "") ASC, member_name'))->get();

$result = $a->merge($b);

Example 3: Union query with Laravel Eloquent

$color = DB::table("item_color")
    ->select("item_color.name"
      ,"item_color.price"
      ,"item_color.qty");
  
$company = DB::table("item_company")
    ->select("item_company.name"
      ,"item_company.price"
      ,"item_company.qty")
    ->union($color)
    ->get();
  
dd($company);

Related Keywords:: union in laravel, union in laravel eloquent, laravel union order by, laravel union query, laravel eloquent union, union all laravel example, laravel 5.7 union query, laravel eloquent union query, laravel query builder union all

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 Database Eloquent Unions Query.
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.