Topic: Technology

Print Debugging Queries in Laravel Example 0

Print Debugging Queries in Laravel Example

Today, We want to share with you Print Debugging Queries in Laravel Example.In this post we will show you Display all SQL executed in Eloquent, hear for How to get last executed query in Larave 5? we will give you demo and example for implement.In this post, we will learn about How to print query or debug queries in Laravel with an example.

Print Debugging Queries in Laravel Example

There are the Following The simple About Print Debugging Queries in Laravel Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Debugging Queries in Laravel, so the Using toSql Function to Print SQL Query in Laravel for this example is following below.

Laravel Debugging Queries with Example

How to print query or debug queries in Laravel

$results = Member::where(function($q) use ($request) {
    $q->orWhere('email', 'like', '%[email protected]%');
    $q->orWhere('member_fname', 'like', '%jaydeep%');
    $q->orWhere('member_lname', 'like', '%Gondaliya%');
})->toSql();
dd($results);

How to get last executed query in Larave 5?

\DB::listen(function($sql, $bindings, $time) {
	//SQL query
    var_dump($sql);
    var_dump($bindings);
    var_dump($time);
});

Debugging Queries in Laravel

$results = Member::where(function($q) use ($request) {
    $q->where('email', 'like', '%[email protected]%');
    $q->where('member_fname', 'like', '%jaydeep%');
    $q->where('member_lname', 'like', '%Gondaliya%');
})->get();
dd($results);

How to get last executed query in Larave 5?

Example 1: laravel tosql with parameters

DB::enableQueryLog();
$member = Member::get();
$sql_qry = DB::getQueryLog();
$sql_qry = end($sql_qry);
print_r($sql_qry);

Example 2: laravel tosql with parameters

DB::enableQueryLog();
$member = Member::get();
$sql_qry = DB::getQueryLog();
print_r($sql_qry);

Example 3: laravel 5.4 get last query

$member = Member::where('id',1)->toSql();
print_r($member);

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 Print Debugging Queries in 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.

Sweet Alert confirmation before delete in Laravel 5.7 0

Sweet Alert confirmation before delete in Laravel 5.7

Today, We want to share with you Sweet Alert confirmation before delete in Laravel 5.7.In this post we will show you sweet alert delete confirmation laravel, hear for Bootstrap SweetAlert Laravel Confirm dialog box model with yes and no option example we will give you demo and example for implement.In this post, we will learn about Laravel Confirmation alert Before Delete record with jQuery AJAX with an example.

Sweet Alert confirmation before delete in Laravel 5.7

There are the Following The simple About Sweet Alert confirmation before delete in Laravel 5.7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop Ajax SweetAlert for Live Data Deleting Rows, so the sweetalert delete confirm laravel for this example is following below.

Step 1: INSTALL LARAVEL 5.6 PROJECT

Laravel 5.6 Project step by step

first of all You Install Laravel latest version Like 5.6 Project by the typing following simple command.Simple Bootstrap SweetAlert Laravel Confirm dialog box model with yes and no option example

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

Step 2: INSTALL SWEET ALERT PACKAGE

And then, I will install the libs a sweet alert package using PHP composer.

composer require uxweb/sweet-alert

config/app.php
'providers' => [
   UxWeb\SweetAlert\SweetAlertServiceProvider::class,
];

//After that, register a facade alias to this same this file at the bottom.
‘aliases’ => [
‘Alert’ => UxWeb\SweetAlert\SweetAlert::class,
];

Step 3: CREATE A LARAVEL CONTROLLER

php artisan make:controller SweetConfirmAlertController

SweetConfirmAlertController.php

It will run command to build the controller file called SweetConfirmAlertController.php.

//SweetConfirmAlertController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Alert;

class SweetConfirmAlertController extends Controller
{
    public function sweetAllnotification($type)
    {
        switch ($type) {
            case 'message':
                Alert::message('Hello Pakainfo.com','Message');
                break;
            case 'basic':
                Alert::basic('Welcome Pakainfo.com','Basic');
                break;
            case 'info':
                Alert::info('Your Simple Pakainfo.com Mail Sent','Info');
                break;
            case 'success':
                Alert::success('Your message(Pakainfo.com) has been successfully sent', 'Success');
                break;
            case 'error':
                Alert::error('Sorry!, Something went wrong','Error');
                break;
            case 'warning':
                Alert::warning('Please Pakainfo.com your SignIn account','Warning');
                break;
            default:
                break;
        }
        return view('product_list');
    }
}

You Can Download Source Code here..Laravel Sweet Alert AJAX CRUD Tutorial

Step 4: DEFINE Laravel 5.7 ROUTE

web.php

We register all route files in a web.php file.

Route::get('product_list/{type}','[email protected]');

Step 5: CREATE A LARAVEL VIEW FILE

resources/views/product_list.blade.php

You can create a file in resources/views/product_list.blade.php as well as put this following source code in it.

<!-- product_list.blade.php -->

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Laravel 5.7 Sweet Alert with Notification Tutorial With Example </title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.0/sweetalert.min.js"></script>
  </head>
  <body>
    <h2>Laravel 5.7 Create custom alert with sweetAlert jQuery</h2>
    @include('sweet::alert')
  </body>
</html>

Last stepTo Run the Laravel 5.7 Application by typing following command.

php artisan serve

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 Sweet Alert confirmation before delete in Laravel 5.7.
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.

JavaScript Image Thumbnails Preview Gallery 0

JavaScript Image Thumbnails Preview Gallery

Today, We want to share with you JavaScript Image Thumbnails Preview Gallery.In this post we will show you javascript image gallery with thumbnails, hear for CSS Image Thumbnail Viewer in javascript Gallery we will give you demo and example for implement.In this post, we will learn about Responsive Image Gallery with Thumbnail Carousel with an example.

JavaScript Image Thumbnails Preview Gallery

There are the Following The simple About JavaScript Image Thumbnails Preview Gallery Full Information With Example and source code.

As I will cover this Post with live Working example to develop jQuery Thumbnail Image Slider – CSS, JavaScript, so the css image gallery with thumbnails for this example is following below.

Example 1: JavaScript Image Thumbnail Viewer Tutorial

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Simple javascript image gallery with thumbnails | Pakainfo.com</title>
<style>
.liveimgpreview {
width:640px;
height:360px}

.gallerythumb {
width:204px;
margin-right:3px;}

.defaultset {
border:3px solid #000000;}

.selected {
border:3px solid #ff0000;}
</style>
</head>
<body>
<h1>Image Thumbnail Viewer</h1>
<img id="0" class="liveimgpreview defaultset" src="" alt="preview" /><br />
<img id="1" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product1" onmouseover="liveimgpreview(this)"/>
<img id="2" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product2" onmouseover="liveimgpreview(this)"/>
<img id="3" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product3" onmouseover="liveimgpreview(this)"/>
<script>

    var lastImg = 1; //Set initial thumbnail and liveimgpreview
    document.getElementById(0).src = document.getElementById(lastImg).src;
    document.getElementById(lastImg).className = "gallerythumb selected";

    function liveimgpreview(img_param) {
        document.getElementById(lastImg).className = "gallerythumb defaultset";
        img_param.className = "gallerythumb selected";
        document.getElementById(0).src = img_param.src;
        lastImg = img_param.id
    }
</script>
</body>
</html>

Example 2: Simple JavaScript Image Thumbnail Viewer

<html>
<head>
    <title>JavaScript Thumbnail Slider</title>
    <style type="text/css">
        .img_container {
            margin: 0 auto;
            width: 191px;
            height: 113px;    
            border: 0;
            overflow: hidden;
            background-color: #FFFFFF;
            webkit-box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);
            -moz-box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);
            box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);    
            border: solid 0px #FFFFFF; 
            border-radius: 4px;
            -moz-border-radius: 4px;
            -webkit-border-radius: 4px;    
            display: block;
        }       
        #gallery {
            margin:0 auto;
            width:200px;
            height:20px;
            position:relative;
            top:-2px;
        }
        .thumbnailSlide {
            text-align:center; 
            width:100%; 
            display:block;
        }
        .thumbnailSlide .btSld {
            margin:3px; 
            padding:4px;
            height:4px;
            text-decoration:none;
            outline:none;
            cursor:pointer; 
            border:solid 2px #FFFFFF;
            border-radius:30px;
            -moz-border-radius:30px; 
            -webkit-border-radius:30px; 
        }
    </style>
</head>
<body>
    <p>Click the little circles below the Product Thumb to slide</p> 
    <div class="img_container">
        <a href="#" rel="">
            <img src="https://www.yourDomainName.com/2019/11/slide/image1.jpg" id="pb1" alt="" border="0" />
        </a>
    </div>
        
    <div id="gallery">
        <div class="thumbnailSlide">
            <input type="button" id="1" class="btSld" 
                style="background-color:#567DD8;"
                onclick="javascript:previewThumb(this.id);" />
            <input type="button" id="2" class="btSld" 
                onclick="javascript:previewThumb(this.id);" />
            <input type="button" id="3" class="btSld" 
                onclick="javascript:previewThumb(this.id);" />
            <input type="button" id="4" class="btSld" 
                onclick="javascript:previewThumb(this.id);" />
        </div>
    </div>
</body>

<script>
    var array_Thumb = new Array();  

    array_Thumb[1] = 'https://www.yourDomainName.com/2019/11/media/Product1.jpg';
    array_Thumb[2] = 'https://www.yourDomainName.com/2019/11/media/Product2.jpg';
    array_Thumb[3] = 'https://www.yourDomainName.com/2019/11/media/Product3.jpg';
    array_Thumb[4] = 'https://www.yourDomainName.com/2019/11/media/Product4.jpg';

    var setThumb;
    var thumbnailCounter = array_Thumb.length - 1;

    var arrThumbCnt = new Array();
    for (setThumb = 1; setThumb < thumbnailCounter + 1; setThumb++) {
        arrThumbCnt[setThumb] = new Image();
        arrThumbCnt[setThumb].src = array_Thumb[setThumb];
    }
        
    function previewThumb(img) {
        document.images.pb1.src = arrThumbCnt[img].src;
            
        for (setThumb = 1; setThumb < thumbnailCounter + 1; setThumb++) {
            
            if (setThumb == img) 
                document.getElementById(setThumb).style.backgroundColor = "#567DD8";
            else 
                document.getElementById(setThumb).style.backgroundColor = "#CCC";
        }
    }
</script>
</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 JavaScript Image Thumbnails Preview Gallery.
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.

Clear Caches Laravel 5.7 using command line 0

Clear Caches Laravel 5.7 using command line

Today, We want to share with you Clear Caches Laravel 5.7 using command line.In this post we will show you Laravel PHP Artisan Config Clear cache Command, hear for Laravel Clear Cache – How to Clear Cache on Views, Config, Route, etc we will give you demo and example for implement.In this post, we will learn about How to clear config cache in Laravel 5.7 using PHP Artisan with an example.

Clear Caches Laravel 5.7 using command line

There are the Following The simple About Clear Caches Laravel 5.7 using command line Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 clear cache programmatically, so the Laravel Clearing the Config Cache for this example is following below.

Clear database cache

Laravel 5.7 clear cache from route, view, config and all cache data from project

In Laravel php artisan cache:clear command is used to clear all the cache.It will delete all the Laravel cache associated with the connection to the database.

Usage:

php artisan cache:clear

Laravel 5.7 clear cache programmatically

Further, on shared hosting, We can use below some part of the source code in your routes/web.php file to delete your Laravel database cache clear.

Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('cache:clear');
    return "Cache is cleared";
});

Clear config cache

To clear config cache of your Laravel project run below command on terminal.

php artisan config:cache  

Clear route cache

To clear Cache Laravel navigation route cache of your Laravel project run below command on terminal.php artisan route:clear deletes the cache file.

php artisan route:cache  

laravel clear config cache

php artisan config:clear reverses the process by all the data removing bootstrap/cache/config.php.

php artisan config:cache

laravel clear route cache

php artisan route:cache

laravel clear bootstrap cache

php artisan config:clear

Clear Cache facade value:

php artisan cache:clear

Clear compiled view files

To clear Cache compiled all the balde view files of your Laravel project issue below command from terminal.artisan view:clear clears all compiled view blade files from Like storage/framework/views/.

php artisan view:clear 

Laravel 5.7 optimization commands

php artisan optimize
php artisan config:cache
php artisan route:cache

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 Caches Laravel 5.7 using command line.
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 Deleting Records From MySQL Table 0

Laravel Deleting Records From MySQL Table

Today, We want to share with you Laravel Deleting Records From MySQL Table.In this post we will show you Laravel delete all records from table, hear for How to Delete Data from MySQL Database Table Using Laravel 5.7 we will give you demo and example for implement.In this post, we will learn about Laravel MySQL Delete & TRUNCATE to remove records from MySQL table with an example.

Laravel Deleting Records From MySQL Table

There are the Following The simple About Laravel Deleting Records From MySQL Table Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to delete all the rows in a table using Eloquent?, so the Laravel – Delete all records from table query for this example is following below.

Syntax : Laravel 5.7 delete all records from table example.Below is the simple example for remove all records from table laravel

DB::table(‘your_database_table_name’)->delete(); is used to delete All records from table using laravel 5.7.

MyModel::truncate();

Laravel 5.6 solution
\App\Model::query()->delete();

Deleting Records In A Table using Laravel 5.7

DB::table('products')->where('votes', '<', 100)->delete();

Laravel Deleting All Records From A Table

DB::table('products')->delete();

Truncating A Table in Laravel

DB::table('products')->truncate();

Example 1: delete all data from table laravel

Product::truncate();

Example 2: laravel eloquent delete where

Product::whereNotNull('id')->delete();

Example 3: laravel delete all records from table

Product:where('id', 'like' '%%')->delete();

Example 4: remove all records from table laravel

DB::table('products')->delete();

Will delete all records from table.

delete multiple rows using Laravel 5.7 Examples

public function destroy(Request $request,$id){
    $product=Product::find($id);
    $product->delete();
    return back()->with('success','Product deleted successfully');
}   

public function deleteMultiple(Request $request){
    $ids = $request->ids;
    Product::whereIn('id',explode(",",$ids))->delete();
    return response()->json(['status'=>true,'message'=>"Product deleted successfully."]);
    
}

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 Deleting Records From MySQL Table.
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.