Topic: Mysqli

Difference between two dates in years, months, days in PHP 0

Difference between two dates in years, months, days in PHP

Today, We want to share with you Difference between two dates in years, months, days in PHP.In this post we will show you calculate the difference between two dates in PHP, hear for PHP Get difference between two dates in years months days hours minutes we will give you demo and example for implement.In this post, we will learn about php difference between two dates in years months and days with an example.

Difference between two dates in years, months, days in PHP

There are the Following The simple About Difference between two dates in years, months, days in PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop calculate days between two dates in php, so the PHP Date Exercises Time difference php calculate time difference between two dates in minutes for this example is following below.

PHP Difference Between Two Dates

PHP Date Exercises Time difference in days and years, months, days, hours, minutes, seconds between two dates

$first_date = new DateTime('2019-06-01 02:12:51');
$second_date = new DateTime('2023-05-12 11:10:00');
$live_date_diff = $first_date->diff($second_date);
echo $live_date_diff->days.'Total days'."\n";
echo $live_date_diff->y.' years'."\n";
echo $live_date_diff->m.' months'."\n";
echo $live_date_diff->d.' days'."\n";
echo $live_date_diff->h.' hours'."\n";
echo $live_date_diff->i.' minutes'."\n";
echo $live_date_diff->s.' seconds'."\n";

You can also make a single simple PHP function/Methods to fetch difference between two dates using PHP in years months, days, hours and minutes that will be very helpful for all some filter data or chart or any project. We won’t need to re-write the source code.

//get Simple difference between two dates in years months, days, hours and minute
$live_date_diff = getDateDiff('2019-06-01 02:12:51','2022-05-12 11:10:00');

print_r($live_date_diff);

function getDateDiff($first_date,$second_date) {
    $first_date = new DateTime($first_date);
    $second_date = new DateTime($second_date);
    $live_date_diff = $first_date->diff($second_date);
    
    $nodeResult['total_days'] = $live_date_diff->days;
    $nodeResult['years'] = $live_date_diff->y;
    $nodeResult['months'] = $live_date_diff->m;
    $nodeResult['days'] = $live_date_diff->d;
    $nodeResult['hours'] = $live_date_diff->h;
    $nodeResult['minutes'] = $live_date_diff->i;
    $nodeResult['seconds'] = $live_date_diff->s ;
    return $nodeResult;
}

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 Difference between two dates in years, months, days in PHP.
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 OOP CRUD MVC Framework Tutorial 0

PHP OOP CRUD MVC Framework Tutorial

Today, We want to share with you PHP OOP CRUD MVC Framework Tutorial.
In this post we will show you php Simple MVC example with source code, hear for CRUD with PHP OOP and MVC we will give you demo and example for implement.
In this post, we will learn about Simple PHP MVC Framework Example with an example.

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.php Simple MVC example with source code

Folder Structure :

******************
===================
MVC
->controller
–>Controller.php
->model
–>user.php
–>Model.php
->view
–>userlist.php
–>viewuser.php
index.php
===================

Source code : Simple php mvc example

index.php

invoke();

?>

Controller.php

username = $username;
	    $this->userfname = $userfname;
	    $this->userinfo = $userinfo;
    } 
}

?>

user.php

username = $username;
	    $this->userfname = $userfname;
	    $this->userinfo = $userinfo;
    } 
}

?>

Model.php

 new Users("only playing", "R. dismelp", "student of the atmiya."),
			"Ravi Korat" => new Users("Moonwalker", "J. Walker", "stud. of th rk collage"),
			"Pragnesh shah" => new Users("hitesh dhameliya", "news boys", "choklate boys")
		);
	}
	public function getBook($username)
	{
		$allBooks = $this->getUserList();
		return $allBooks[$username];
	}
}
?>

userlist.php

<title>php Simple MVC example with source code</title>

<table>
	<tr><td>User Name</td><td>UserFirstName</td><td>UserInfo</td></tr>
	 $users)
		{
			echo '<tr><td><a>username.'">'.$users->username.'</a></td><td>'.$users->userfname.'</td><td>'.$users->userinfo.'</td></tr>';
		}

	?>
</table>


viewuser.php



<title>php Simple MVC example with source code</title>


username . '<br />';
	echo 'userfname:' . $user->userfname . '<br />';
	echo 'userinfo:' . $user->userinfo . '<br />';
?>



MVC run : http://localhost/mvc/

PHP sleep delay Function increasing execution time 0

PHP sleep delay Function increasing execution time

Today, We want to share with you PHP sleep delay Function increasing execution time.In this post we will show you Php, wait 5 seconds before executing an action, hear for jQuery delay Effects with Animation Example we will give you demo and example for implement.In this post, we will learn about Adding delay to the script execution time in PHP by using PHP sleep function with an example.

PHP sleep delay Function increasing execution time

There are the Following The simple About PHP sleep delay Function increasing execution time Full Information With Example and source code.

As I will cover this Post with live Working example to develop Delay, sleep, pause, wait etc in PHP, so the delay(sleep) a PHP function call using PHP for this example is following below.

PHP sleep() Function

The PHP sleep() methods delays some execution of the active script for a (delay)specified number of seconds.

Syntax

sleep(seconds)

Using PHP sleep to add some times delay or increase your script execution time

sleep(25);

The above PHP command will make a PHP delay of 25 seconds, the next process of script execution will be after the some delay of 25 seconds.

Simple PHP sleep delay Examples

Let us print some time the time after a delay(sleep) a PHP function call using PHP of 15 seconds.

<?php
echo date('H:i:s');
sleep(15);
flush();
echo "<br>";
echo date('H:i:s');
?>

Out of the two Simple php sleepoutpus , second one will return display after 15 secs

12:22:19
--------------
12:22:34

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 sleep delay Function increasing execution time.
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.

PHP MySQL Column Sorting Examples 0

PHP MySQL Column Sorting Examples

Today, We want to share with you PHP MySQL Column Sorting Examples.In this post we will show you Column Sorting using PHP and MySQL, hear for Server-side Processing DataTables using PHP with MySQL we will give you demo and example for implement.In this post, we will learn about Laravel Datatable Pagination Sorting and Search server side processing with an example.

PHP MySQL Column Sorting Examples

There are the Following The simple About PHP MySQL Column Sorting Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop Jquery Datatable listing json Server side in Php Mysql and Ajax, so the sorting data from database in php for this example is following below.

Create products table:

Here, we will create products table by following sql query:

CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(80) NOT NULL,
  `srno` varchar(244) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

Create index.php file:

<!DOCTYPE html>
<html>
<head>
  <title>Column Sorting using PHP and MySQL - pakainfo.com</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
</head>
<body>
 
<div class="container">
  <h1>Column Sorting using PHP and MySQL - pakainfo.com</h1>
  <p>MySQL ORDER BY - Sort a Result Set in MySQL using PHP Examples</p>
<?php
     
    $hostName = "localhost";
    $db_uname = "atmiya";
    $db_pass = "jaydeepGondaliya";
    $dbname = "inv_system"; 
    $mysqli = new mysqli($hostName, $db_uname, $db_pass, $dbname); 
    $productOrderby = !empty($_GET["orderby"]) ? $_GET["orderby"] : "name";
 
    $order = !empty($_GET["order"]) ? $_GET["order"] : "asc";
 
    $sql = "SELECT * FROM products ORDER BY " . $productOrderby . " " . $order;
  
    $result = $mysqli->query($sql);
  
    $order_Name = "asc";
    $srnoOrder = "asc";
  
    if($productOrderby == "name" && $order == "asc") {
      $order_Name = "desc";
    }
    if($productOrderby == "srno" && $order == "asc") {
      $srnoOrder = "desc";
    }
?>
<table class="table table-bordered">
  <thead>
    <tr>
      <th><a href="?orderby=name&order=<?php echo $order_Name; ?>">Product Name</a></th>
      <th><a href="?orderby=srno&order=<?php echo $srnoOrder; ?>">SR.NO</a></th>
    </tr>
  </thead>
  <tbody>
  
    <?php
    while($row = mysqli_fetch_assoc($result)){
    ?>
      <tr>
        <td><?php echo $row['name']; ?></td>
        <td><?php echo $row['srno']; ?></td>
      </tr>
    <?php
    }
    ?>
  
  </tbody>
</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 PHP MySQL Column Sorting Examples.
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 Yii Maintenance Mode Tutorial with Examples 0

PHP Yii Maintenance Mode Tutorial with Examples

Today, We want to share with you PHP Yii Maintenance Mode Tutorial with Examples.
In this post we will show you Yii Maintenance Mode, hear for Programming With Yii2: Routing and URL Creation we will give you demo and example for implement.
In this post, we will learn about php – yii toggle maintenance mode ON/OFF with an example.

The Yii Maintenance ModeAny User can simple Display access maintenance Mode or file only View in HTML Page.

  • The Yii Maintenance Controller
  • The Yii Maintence File

The Yii Maintenance Controller

Create or Point the Yii Simple controller main Logix action to page display maintenance mode.

return array(
    'catchAllRequest'=> array('site/yii_maintenance'),
    ............   

The Yii Maintence File

Create or Point the Yii sersver side file to maintenance or processing mode. If the check simple condition here Like PHP functions file_exists() return boolean value false, The PHP Based yii maintenance mode will be simple check switch off or not work.

'catchAllRequest'=>file_exists(dirname(__FILE__).'/.yii_maintenance')? array('site/yii_maintenance') : null,

Read :

Summary

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

I hope you get an idea about How to implement “Maintenance Mode” in Yii.
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.

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

Apache Htaccess HTTP Server Tutorial 0

Apache Htaccess HTTP Server Tutorial

Today, We want to share with you Apache Htaccess HTTP Server Tutorial.
In this post we will show you Apache .htaccess file – Examples and Common Uses | htacces Download, hear for Apache Htaccess Programming Tutorial And Examples we will give you demo and example for implement.
In this post, we will learn about What is .htaccess? – Apache .htaccess Guide, Tutorials & Examples with an example.

How to Create a simple .htaccess File?

Simple Open any text editor Like as a (Notepad++) application and file save (.htaccess) as with .htaccess name and simple enable mod_rewrite extension in change to php.ini file in Apache (linux server) Web Server configurations.

Simple Making .htaccess file

|htdocs
|-Images
|-js
|-index.php
|-.htaccess

Domain Redirection(How do I redirect one domain to another domain name? – SiteGround)

 .htacces code for redirecting Pakainfo.com.com to www.Pakainfo.com.com

Solution

RewriteCond %{HTTP_HOST} ^Pakainfo.com.com
RewriteRule (.*) http://www.Pakainfo.com.com/$1 [R=301,L]

Download

Sub Domain Redirection(How to redirect a subdomain to another page)

 Sub domain redirection mapping to folder. Here http://www.Pakainfo.com.com is connecting to web_folder_name folder. 

Solution 1

RewriteCond %{HTTP_HOST} ^www\.Pakainfo.com\.com$
RewriteCond %{REQUEST_URI} !^/web_folder_name/
RewriteRule (.*) /web_folder_name/$1

Solution 2

Here http://subdomain.Pakainfo.com.com is connecting to subweb_folder_name folder.

RewriteCond %{HTTP_HOST} ^subdomain\.Pakainfo.com\.com$
RewriteCond %{REQUEST_URI} !^/subweb_folder_name/
RewriteRule (.*) /subweb_folder_name/$1

Download

Old Domain Redirection(Redirect an Old Domain to a New Domain with .htaccess)

demo w3free.com is now redirecting to pakainfo.com

Solution

RewriteCond %{HTTP_HOST} ^Pakainfo.com
RewriteRule (.*) http://www.live24.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.pakainfo\.com
RewriteRule (.*) http://www.Pakainfo.com/$1 [R=301,L]

Download

Disable directory Listing (How to Prevent a Directory Listing of Your Website with .htaccess)

# Disable Directory Browsing
Options All -Indexes

Download

Simple Hide .php(filename) extension with URL Rewriting (how to remove php extension from url without htaccess)

RewriteEngine on
RewriteRule ^(.*)$ $1.php 

Download

Convert index.php to index.html using htacces

RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php 

Download

Redirecting www URL to non www URL

  
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.Pakainfo.com
RewriteRule (.*) https://pakainfo.com/$1 [R=301,L]

Download

Friendly URLs

Friendly URLs (userfriends seo Friendly)help in search engine rankings.

aboutus URL Examples

https://pakainfo.com/aboutus.php?userparamname=itking
to
https://pakainfo.com/itking

Solution

RewriteRule ^([a-zA-Z0-9_-]+)$ aboutus.php?userparamname=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ aboutus.php?userparamname=$1

Download

msgstatus URL Examples

https://pakainfo.com/msgstatus.php?msg_user_name=itking
to
https://pakainfo.com/msgstatus/itking

Solution

RewriteRule ^msgstatus/([a-zA-Z0-9_-]+)$ msgstatus.php?msg_user_name=$1
RewriteRule ^msgstatus/([a-zA-Z0-9_-]+)/$ msgstatus.php?msg_user_name=$1

Download

userfriends URL Examples

https://pakainfo.com/userfriends.php?userparamname=itking
to
https://pakainfo.com/userfriends/itking

Solution

RewriteRule ^userfriends/([a-zA-Z0-9_-]+)$ userfriends.php?userparamname=$1
RewriteRule ^userfriends/([a-zA-Z0-9_-]+)/$ userfriends.php?userparamname=$1

Download

userfriends URL with Two Parameters (htaccess rewrite url get parameters)

https://pakainfo.com/userfriends.php?userparamname=itking&page=2
to
https://pakainfo.com/userfriends/itking/2

Solution

RewriteRule ^userfriends/([a-zA-Z0-9_-]+)/([0-9]+)$ userfriends.php?userparamname=$1&page=$2
RewriteRule ^userfriends/([a-zA-Z0-9_-]+)/([0-9]+)/$ userfriends.php?userparamname=$1&page=$2

Download

Hiding File Extension(How to remove .php, .html, .htm extensions with .htaccess)

http://www.Pakainfo.com.com/index.html
to
http://www.Pakainfo.com.com/index

Solution

 RewriteRule ^([^/.]+)/?$ $1.html

Download

Laravel Bootstrap Toggle switch Update DB field using Ajax 0

Laravel Bootstrap Toggle switch Update DB field using Ajax

Today, We want to share with you Laravel Bootstrap Toggle switch Update DB field using Ajax.In this post we will show you Bootstrap Toggle switch Update Database field using Ajax, hear for Create Stylish Toggles Checkboxes & Use in Form with Laravel Ajax we will give you demo and example for implement.In this post, we will learn about bootstrap toggle switch with ajax update to mysql in Laravel 5.7 with an exampleLaravel 5.7 Toggle switch Update DB field using Ajax.

Laravel Bootstrap Toggle switch Update DB field using Ajax

There are the Following The simple About Laravel Bootstrap Toggle switch Update DB field using Ajax Full Information With Example and source code.

As I will cover this Post with live Working example to develop Bootstrap Toggle to Update Database in Laravel 5.7, so the some major files and Directory structures for this example is following below Laravel Toggle Switch Inside Bootstrap Ajax Example.

Step 1: Include CDN and HTML Code

laravel-toggle-switch-button

<script defer src="https://use.fontawesome.com/releases/v5.0.4/js/all.js"></script>

<h2>Manage data using switch/toggle button on html with Laravel</h2>
<button class="btn" onclick="save">
  @if ($saved == true)
    <i id="save-icon" class="fas fa-star"></i><span id="save">Saved!</span>
  @else
    <i id="save-icon" class="far fa-star"></i><span id="save">Save</span>
  @endif
</button>

Step 2: JavaScript Function

function save() {
    var saveEl = document.getElementById("save-icon");
    var iconType = saveEl.getAttribute("data-prefix");
}

Step 3: Ajax Http Call in jQuery

if ( iconType === 'fas' ) {
  $.ajax({
    url: "/unsave-product",
    cache: false,
    data: {
        slug: productSlug,
        userId: {{ $userId }}
    }
  })
  .done(function (response) {
      document.getElementById("save-icon").classList.add("far");
      document.getElementById("save").innerHTML="Save";
  })
  .fail(function () {
      console.log('failure');
  });
} else {
    $.ajax({
        url: "/save-product",
        cache: false,
        data: {
            slug: productSlug,
            userId: {{ $userId }}
        }
    })
        .done(function (response) {
            document.getElementById("save-icon").classList.add("fas");
            document.getElementById("save").innerHTML = "Saved!";
        })
        .fail(function () {
            console.log('failure');
        });
}

Step 4: Create A Laravel Controller

And Last to update query in Database to Save and unsave Product Details.

public function unsave(Request $request) {
    $product = product::where('slug', $request->input('slug'))->first();
    $savedProduct = savedProducts::where([
        ['user_id', $request->input('userId')],
        ['product_id', $product->id]
    ])->first();

    $savedProduct->delete();
}

public function save(Request $request) {
    $product = product::where('slug', $request->input('slug'))->first();

    $savedProduct = new savedProducts();
    $savedProduct->user_id = $request->input('userId');
    $savedProduct->product_id = $product->id;
    $savedProduct->save();
}

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 Bootstrap Toggle switch Update DB field using 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.