CODE VN

CODE VN

1649357940

Cách thêm ReCAPTCHA của Google v3 với Laravel

Trong hướng dẫn này, bạn sẽ học cách thêm google v3 ReCAPTCHA với laravel 8 dạng.

1: Cài đặt ứng dụng Laravel 8

Trong bước 1, mở thiết bị đầu cuối của bạn và điều hướng đến thư mục máy chủ web cục bộ của bạn bằng lệnh sau:

//for windows user
cd xampp/htdocs

//for ubuntu user
cd var/www/html

Sau đó cài đặt ứng dụng laravel 8 mới nhất bằng lệnh sau:

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

 

2: Định cấu hình chi tiết cơ sở dữ liệu

Ở bước 2, mở ứng dụng laravel 8 đã tải xuống của bạn vào bất kỳ trình soạn thảo văn bản nào. Sau đó tìm tệp .env và định cấu hình chi tiết cơ sở dữ liệu như sau:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db name
DB_USERNAME=db user name
DB_PASSWORD=db password

3: Cài đặt Gói Google Recaptcha V3

Trong bước 3, mở dấu nhắc lệnh và điều hướng đến dự án của bạn bằng cách sử dụng lệnh sau:

cd / LaravelGoogleV3Recaptcha

Sau đó chạy lệnh sau để cài đặt gói xác thực recaptcha google v3 trong ứng dụng xác thực recaptcha google v3 laravel 8:

composer require josiasmontag/laravel-recaptchav3

Sau khi cài đặt thành công gói này. Theo tùy chọn, bạn có thể xuất bản tệp cấu hình:

php artisan vendor:publish --provider="Lunaweb\RecaptchaV3\Providers\RecaptchaV3ServiceProvider"

Sau đó thêm khóa trang web và khóa bí mật trên tệp .env do trang web google recaptcha cung cấp. Như sau:

RECAPTCHAV3_SITEKEY=secret_site_key
RECAPTCHAV3_SECRET=secret_key 

Nếu bạn không đăng ký trang web của mình với trang web google v3 recaptcha. Vì vậy, bạn có thể truy cập liên kết này . Và đăng ký trang web của bạn bằng cách nộp đơn giản trên google form.

Sau đó, bạn sẽ nhận được id khách hàng google và bí mật từ trang web Google Recaptcha.

4: Tạo mô hình & di chuyển

Trong bước 4, tạo mô hình và tệp di chuyển cho biểu mẫu liên hệ với chúng tôi bằng cách sử dụng lệnh sau:

php artisan make:model ContactUs -m

Lệnh trên sẽ tạo hai tệp vào ứng dụng xác thực laravel 8 google v3 recaptcha của bạn, nằm bên trong các vị trí sau:

  • LaravelGoogleV3Recaptcha / app / Models / ContactUs.php
  • LaravelGoogleV3Recaptcha / database / migrations / create_contact_us_table.php

Vì vậy, hãy tìm tệp create_contact_us_table.php bên trong thư mục LaravelGoogleV3Recaptcha / database / migrations / . Sau đó, mở tệp create_contact_us.php và thêm mã sau vào hàm up () trên tệp này:

public function up()
{
    Schema::create('contact_us', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('email');
        $table->string('subject');
        $table->text('message');
        $table->timestamps();
    });
}

Bây giờ, hãy mở lại thiết bị đầu cuối của bạn và nhập lệnh sau vào cmd để tạo bảng vào cơ sở dữ liệu đã chọn của bạn:

php artisan migrate

5: Tạo các tuyến đường

Trong bước 5, mở tệp web.php của bạn, nằm bên trong thư mục các tuyến đường. Sau đó, thêm các tuyến sau vào tệp web.php:

use App\Http\Controllers\GoogleV3CaptchaController;
 
Route::get('google-v3-recaptcha', [GoogleV3CaptchaController::class, 'index']);
Route::post('validate-g-recaptcha', [GoogleV3CaptchaController::class, 'validateGCaptch']);

6: Tạo bộ điều khiển

Trong bước 6, tạo trình điều khiển recaptcha của Google v3 bằng cách sử dụng lệnh sau:

php artisan make:controller GoogleV3CaptchaController

Lệnh trên sẽ tạo tệp GoogleV3CaptchaController.php , nằm trong thư mục LaravelGoogleV3Recaptcha / app / Http / Controllers / .

Các quy tắc xác thực laravel sau đây sẽ xác thực dữ liệu biểu mẫu recaptcha của google trước khi lưu vào cơ sở dữ liệu trong laravel:

$validatedData = $request->validate([
    'name' => 'required',
    'email' => 'required',
    'subject' => 'required',
    'message' => 'required',
    'g-recaptcha-response' => 'required|recaptchav3:contact-us,0.5'
 
]);

Vì vậy, hãy mở tệp GoogleV3CaptchaController.php và thêm mã sau vào đó:

<?php
 
namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
use App\Models\ContactUs;
 
 
class GoogleV3CaptchaController extends Controller
{
    public function index()
    {
        return view('google-v3-recaptcha');
    }
 
    public function validateGCaptch(Request $request)
    {
         
        $validatedData = $request->validate([
            'name' => 'required',
            'email' => 'required',
            'subject' => 'required',
            'message' => 'required',
            'g-recaptcha-response' => 'required|recaptchav3:contact-us,0.5'
 
        ]);
 
 
        $save = new ContactUs;
 
        $save->name = $request->name;
        $save->email = $request->email;
        $save->subject = $request->subject;
        $save->message = $request->message;
 
        $save->save();
 
        return redirect('google-v3-recaptcha')->with('status', 'Google V3 Recaptcha has been validated form');
 
    }
}

7: Tạo tệp Blade

Trong bước 7, tạo tệp dạng xem phiến mới có tên google-v3-recaptcha.blade.php bên trong thư mục tài nguyên / chế độ xem để hiển thị biểu mẫu liên hệ với chúng tôi với xác thực google v3 recaptcha trong laravel.

Một điều nữa để sử dụng google v3 recaptcha với các biểu mẫu laravel, bạn cần thêm đoạn mã sau vào biểu mẫu laravel:

{!! RecaptchaV3::initJs() !!}
 
{!! RecaptchaV3::field('contact-us') !!}

Đừng lo lắng, chúng tôi đã thêm mã hiển thị thông báo lỗi xác thực cùng với từng trường biểu mẫu và mã xác thực google v3 recaptcha.

Vì vậy, bạn có thể thêm mã biểu mẫu php và html sau vào google-v3-recaptcha.blade.php :

<!DOCTYPE html>
<html>
<head>
<title>How to Use Google V3 Recaptcha Validation In Laravel 8 Form</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
@if(session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
<div class="card">
<div class="card-header text-center font-weight-bold">
<h2>Laravel 8 Contact Us - Adding Google V3 Recaptcha</h2>
</div>
<div class="card-body">
<form name="g-v3-recaptcha-contact-us" id="g-v3-recaptcha-contact-us" method="post" action="{{url('validate-g-recaptcha')}}">
@csrf
<div class="form-group">
<label for="exampleInputEmail1">Name</label>
<input type="text" id="name" name="name" class="@error('name') is-invalid @enderror form-control">
@error('name')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
</div>          
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" id="email" name="email" class="@error('email') is-invalid @enderror form-control">
@error('email')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
</div>           
<div class="form-group">
<label for="exampleInputEmail1">Subject</label>
<input type="text" id="subject" name="subject" class="@error('subject') is-invalid @enderror form-control">
@error('subject')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
</div>      
<div class="form-group">
<label for="exampleInputEmail1">Description</label>
<textarea name="description" class="@error('description') is-invalid @enderror form-control"></textarea>
@error('description')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
</div>
<div class="form-group">
{!! RecaptchaV3::initJs() !!}
{!! RecaptchaV3::field('contact-us') !!}
@error('g-recaptcha-response')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>    
</body>
</html>

8: Khởi động Máy chủ Phát triển

Ở bước 8, hãy mở lại dấu nhắc lệnh của bạn và chạy lệnh sau để khởi động máy chủ phát triển cho ứng dụng xác thực biểu mẫu recaptcha laravel 8 google v3 của bạn:

php artisan serve

9: Chạy ứng dụng xác thực Google V3 Recaptcha Laravel 8 trên trình duyệt

Trong bước 9, mở trình duyệt của bạn và kích hoạt url sau vào trình duyệt của bạn:

http://127.0.0.1:8000/google-v3-recaptcha

What is GEEK

Buddha Community

Eleo Nona

Eleo Nona

1600916549

Laravel 8 Google Recaptcha V3 Example

Laravel 8 google ReCAPTCHA v3 form validation. In this tutorial, we will share with you how to implement google v3 ReCAPTCHA with laravel 8 forms.

Laravel implement google v3 Recaptcha tutorial, you will learn how to add google v3 Recaptcha with the contact us form in laravel 8.

Laravel google v3 recaptcha form validation apps looks like in following image:

Adding Google reCAPTCHA v3 In Laravel 8 Form

  • Step 1 – Install Laravel 8 Application
  • Step 2 – Configure Database Details
  • Step 3 – Install Google V3 Recaptcha Package
  • Step 4 – Create Model & Migration
  • Step 5 – Create Routes
  • Step 6 – Create Controller
  • Step 7 – Create Blade File
  • Step 8 – Start Development Server
  • Step 9 – Run This App On Browser

#laravel #laravel 8 #google #recaptcha

Laravel 8 Socialite Login with Google Account

Hello Guys,

Today I will share laravel 8 socialite login with google account. In this post give you example of laravel 8 socialite login with google account and also you can knowledge about how to socialite login with google account in laravel 8 jetstream.

This tutorial will give you very easy and simple example of login with gmail in laravel 8.

Read More : Laravel 8 Socialite Login with Google Account

https://websolutionstuff.com/post/laravel-8-socialite-login-with-google-account


Read More : How To Create Dynamic Pie Chart In Laravel

https://websolutionstuff.com/post/how-to-create-dynamic-pie-chart-in-laravel


Read Also : Stripe Payment Gateway Integration Example In Laravel 8

https://websolutionstuff.com/post/stripe-payment-gateway-integration-example-in-laravel-8

#laravel 8 socialite login with google account #laravel #laravel 8 login with google #login with gmail account #laravel socialite #login with gmail in laravel 8

How to Add Google ReCAPTCHA V3 in CodeIgniter 4

Google reCAPTCHA v3 is an invisible type of captcha where the user doesn’t have to interact. It tracks the user behavior on the site and returns a score between 0 to 1 with the response.

This score is use for validation on the server side.

In this tutorial, I show how you can add Google reCAPTCHA v3 to your form in CodeIgniter 4.

Contents

  1. Get Google reCaptcha keys
  2. Create variables in .env
  3. Enable CSRF
  4. Create custom validation for reCaptcha v3
  5. Create Controller
  6. Routes
  7. Create View
  8. Output
  9. Conclusion

1. Get Google reCaptcha keys

You can skip this step if you already registered for Google reCAPTCHA v3 and have site and secret keys.

  • Navigate to the following link and login into your account if not logged in.
  • Following page will display.

Google reCAPTCHA create form

  • Here, enter label, select reCAPTCHA v3 from the reCAPTCHA type, enter your domain name without https e.g. makitweb.com. You can also specify localhost if you want to test it on your local system.
  • Check the Accept the reCAPTCHA Terms of Service and click the Submit button.

Google recaptcha v3 details

  • Copy the site and secret keys.

Google recaptcha v3 site and secret keys


2. Create variables in .env

  • Open .env file which is available at the project root.

NOTE – If dot (.) not added at the start then rename the file to .env.

  • Here, define 2 variables for storing the captcha site and secret keys –
GOOGLE_RECAPTCHAV3_SITEKEY = 6LdP-nIhAAAAAA6rzq7BTh_jKqIYeKMoaALxkKte
GOOGLE_RECAPTCHAV3_SECRETKEY = 6LdV-nIhAAAAAL-uFI4w9kQUaqMkeU2K3KojlXyE

3. Enable CSRF

  • Again open .env file.
  • Remove # from the start of the security.tokenName,security.headerName, security.cookieName, security.expires,and security.regenerate.
  • I update the security.tokenName value with 'csrf_hash_name'. With this name read CSRF hash. You can update it with any other value.
  • If you don’t want to regenerate CSRF hash after each request then set security.regenerate = false.
security.tokenName = 'csrf_hash_name' 
security.headerName = 'X-CSRF-TOKEN' 
security.cookieName = 'csrf_cookie_name' 
security.expires = 7200 
security.regenerate = true
  • Open app/Config/Filters.php file.
  • Uncomment 'csrf' in 'before' if commented.
// Always applied before every request
public $globals = [
    'before' => [
         // 'honeypot',
         'csrf',
         // 'invalidchars',
    ],
    'after' => [
        'toolbar',
        // 'honeypot',
        // 'secureheaders',
    ],
];

4. Create custom validation for reCaptcha v3

Create a rule to verify reCaptcha v3 response.

  • Create a new CaptchaValidation.php file in app/Config/ folder.
  • Create a CaptchaValidation class.
  • In the class create verifyrecaptchaV3() method. Here, the method name is also a rule name.
  • Read the secret key from .env file and assign it to $secretkey.
  • Send request to –
https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$str."&remoteip=".$_SERVER['REMOTE_ADDR']
  • Here, pass secret key, recaptcha response, and IP address.
  • It returns a JSON response.
  • If $responseData->success is true and $responseData->score is > 0.6 then return true otherwise, assign error message in $error and return false.

NOTE – You can update value of $score from 0.6 to any other value. Make sure to set it between 0.5 to 1.

Completed Code

<?php 
namespace Config;

class CaptchaValidation{

     public function verifyrecaptchaV3(string $str, ?string &$error = null): bool
     {
          $secretkey = getenv('GOOGLE_RECAPTCHAV3_SECRETKEY');

          if(($str) && !empty($str)) {

               $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$str."&remoteip=".$_SERVER['REMOTE_ADDR']);

               $responseData = json_decode($response);
               $score = 0.6; // 0 - 1
               if($responseData->success && $responseData->score > $score) { // Verified
                    return true;
               }
          }

          $error = "Invalid captacha";

          return false;
     }

}

To use the above-created validation rule need to define it in the Validation.php file.

  • Open app/Config/Validation.php file.
  • Include Config\CaptchaValidation class.
  • Specify CaptchaValidation::class in $ruleSets Array.

Completed Code

<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\CreditCardRules;
use CodeIgniter\Validation\FileRules;
use CodeIgniter\Validation\FormatRules;
use CodeIgniter\Validation\Rules;
use Config\CaptchaValidation; // Custom reCAPTCHA v3 validation

class Validation extends BaseConfig
{
      // --------------------------------------------------------------------
      // Setup
      // --------------------------------------------------------------------

      /**
      * Stores the classes that contain the
      * rules that are available.
      *
      * @var string[]
      */
      public $ruleSets = [
          Rules::class,
          FormatRules::class,
          FileRules::class,
          CreditCardRules::class,
          CaptchaValidation::class, // Custom reCAPTCHA v3 validation
      ];

      /**
      * Specifies the views that are used to display the
      * errors.
      *
      * @var array<string, string>
      */
      public $templates = [
          'list' => 'CodeIgniter\Validation\Views\list',
          'single' => 'CodeIgniter\Validation\Views\single',
      ];

      // --------------------------------------------------------------------
      // Rules
      // --------------------------------------------------------------------
}

5. Create Controller

Create PagesController Controller –

php spark make:controller PagesController
  • Open app/Controllers/PagesController.php file.
  • Create 2 methods –
    • index() – Load index view.
    • submitContactUs() – This method calls on form submit.

Validate the submitted values. Here, for validating recaptcha specify – 'recaptch_response' => 'required|verifyrecaptchaV3',.

verifyrecaptchaV3 is a custom validation rule created in the previous step.

If <form > is not validated then return to the page with error messages otherwise store the success message in SESSION flash and redirect to route('/').

Completed Code

<?php

namespace App\Controllers;

use App\Controllers\BaseController;

class PagesController extends BaseController
{
     public function index(){
         return view('index'); 
     }

     public function submitContactUs(){

         // Validation
         $input = $this->validate([
              'name' => 'required',
              'email' => 'required',
              'subject' => 'required',
              'message' => 'required',
              'recaptcha_response' => 'required|verifyrecaptchaV3',
            ],[
              'recaptcha_response' => [
                    'required' => 'Please verify captcha',
              ],
         ]);

         if (!$input) { // Not valid

              $data['validation'] = $this->validator;

              return redirect()->back()->withInput()->with('validation', $this->validator);

         }else{ 
              // Set Session
              session()->setFlashdata('message', 'Request Submitted Successfully!');
              session()->setFlashdata('alert-class', 'alert-success');

         }
         return redirect()->route('/');
     }

}

6. Routes

  • Open app/Config/Routes.php file.
  • Here, create 2 routes –
    • page/submitContactUs – Handle form submit.
$routes->get('/', 'PagesController::index');
$routes->post('page/submitContactUs', 'PagesController::submitContactUs');

7. Create View

  • Create index.php file in app/Views/ folder.
  • Include recaptcha js in <head > section –
<!-- reCAPTCHA JS-->
<script src="https://www.google.com/recaptcha/api.js?render=<?= getenv('GOOGLE_RECAPTCHAV3_SITEKEY') ?>"></script>

Here, also specify sitekey.

  • Create a contact form and set action URL to <?=site_url('page/submitContactUs')?>. Define onSubmit event on <form > that calls onSubmit(event).
  • Display an error message if <form> element is not validated. In the <form > also display an error message if recaptcha is not validated.
  • Create a hidden element #recaptcha_response to store recapatcha token response on <form > submit.
  • Create a submit button.

Script

  • Create onSubmit() function that calls on <form > submit.
  • Call grecaptcha.execute on submit action to get a token.
  • Assign the token to the hidden element #recaptcha_response.
  • Submit the <form >.

Completed Code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>How to add Google reCAPTCHA v3 in CodeIgniter 4</title>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" >

    <!-- reCAPTCHA JS-->
    <script src="https://www.google.com/recaptcha/api.js?render=<?= getenv('GOOGLE_RECAPTCHAV3_SITEKEY') ?>"></script>

    <!-- Include script -->
    <script type="text/javascript">

    function onSubmit(e) {
        e.preventDefault();
        grecaptcha.ready(function() {
             grecaptcha.execute("<?= getenv('GOOGLE_RECAPTCHAV3_SITEKEY') ?>", {action: 'submit'}).then(function(token) {

                  // Store recaptcha response
                  document.getElementById("recaptcha_response").value = token;

                  // Submit form
                  document.getElementById("contactForm").submit();

             });
        });
    }

    </script>
</head>
<body>

    <div class="container">

        <div class="row">
             <div class="col-md-6 mt-5" style="margin: 0 auto;">

                 <?php 
                 // Display Response
                 if(session()->has('message')){
                 ?>
                      <div class="alert <?= session()->getFlashdata('alert-class') ?>">
                           <?= session()->getFlashdata('message') ?>
                      </div>
                 <?php
                 }
                 ?>

                 <h2 class="mb-4">Contact US</h2>

                 <?php $validation = \Config\Services::validation(); ?>

                 <form id="contactForm" method="post" action="<?=site_url('page/submitContactUs')?>" onSubmit="onSubmit(event)">

                     <?= csrf_field(); ?>

                     <!-- Recaptcha Error -->
                     <?php if( $validation->getError('recaptcha_response') ) {?>

                          <div class="alert alert-danger">
                                <?= $validation->getError('recaptcha_response'); ?>
                          </div>
                     <?php }?>

                     <div class="form-group mb-4">
                          <label class="control-label col-sm-2" for="name">Name:</label>
                          <div class="col-sm-10">
                                <input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" value="<?= old('name') ?>">
                          </div>

                          <!-- Error -->
                          <?php if( $validation->getError('name') ) {?>
                                <div class='text-danger mt-2'>
                                     * <?= $validation->getError('name'); ?>
                                </div>
                          <?php }?>
                     </div>
                     <div class="form-group mb-4">
                          <label class="control-label col-sm-2" for="email">Email:</label>
                          <div class="col-sm-10">
                                <input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" value="<?= old('email') ?>">
                          </div>

                          <!-- Error -->
                          <?php if( $validation->getError('email') ) {?>
                                <div class='text-danger mt-2'>
                                     * <?= $validation->getError('email'); ?>
                                </div>
                          <?php }?>
                     </div>
                     <div class="form-group mb-4">
                          <label class="control-label col-sm-2" for="subject">Subject:</label>
                          <div class="col-sm-10">
                                <input type="text" class="form-control" id="subject" placeholder="Enter Subject" name="subject" value="<?= old('subject') ?>" >
                          </div>

                          <!-- Error -->
                          <?php if( $validation->getError('subject') ) {?>
                                <div class='text-danger mt-2'>
                                     * <?= $validation->getError('subject'); ?>
                                </div>
                          <?php }?>
                     </div>
                     <div class="form-group mb-4">
                          <label class="control-label col-sm-2" for="message">Message:</label>
                          <div class="col-sm-10">
                                <textarea class="form-control" id="message" name="message"><?= old('message') ?></textarea>
                          </div>

                          <!-- Error -->
                          <?php if( $validation->getError('message') ) {?>
                                <div class='text-danger mt-2'>
                                     * <?= $validation->getError('message'); ?>
                                </div>
                          <?php }?>
                     </div>

                     <div class="form-group "> 
                          <div class="col-sm-offset-2 col-sm-10">
                                <input type="hidden" id="recaptcha_response" name="recaptcha_response" value="">
                                <button type="submit" class="btn btn-info">Submit</button>
                          </div>
                     </div>
                 </form>
             </div>
        </div>

    </div>

</body>
</html>

8. Output

View Output


9. Conclusion

Using this you can protect your website without forcing the user to verify whether it is human or a bot.

You can also view this tutorial if you want to know Google reCAPTCHA v2 implementation in CodeIgniter 4.

If you found this tutorial helpful then don't forget to share.

Original article source at: https://makitweb.com/

#codeigniter #recaptcha #google 

Seamus  Quitzon

Seamus Quitzon

1595201363

Php how to delete multiple rows through checkbox using ajax in laravel

First thing, we will need a table and i am creating products table for this example. So run the following query to create table.

CREATE TABLE `products` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Next, we will need to insert some dummy records in this table that will be deleted.

INSERT INTO `products` (`name`, `description`) VALUES

('Test product 1', 'Product description example1'),

('Test product 2', 'Product description example2'),

('Test product 3', 'Product description example3'),

('Test product 4', 'Product description example4'),

('Test product 5', 'Product description example5');

Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name','description'
    ];
}

Step 2: Create Route

Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.

routes/web.php

Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);

#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete

Google's TPU's being primed for the Quantum Jump

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

As the world is gearing towards more automation and AI, the need for quantum computing has also grown exponentially. Quantum computing lies at the intersection of quantum physics and high-end computer technology, and in more than one way, hold the key to our AI-driven future.

Quantum computing requires state-of-the-art tools to perform high-end computing. This is where TPUs come in handy. TPUs or Tensor Processing Units are custom-built ASICs (Application Specific Integrated Circuits) to execute machine learning tasks efficiently. TPUs are specific hardware developed by Google for neural network machine learning, specially customised to Google’s Machine Learning software, Tensorflow.

The liquid-cooled Tensor Processing units, built to slot into server racks, can deliver up to 100 petaflops of compute. It powers Google products like Google Search, Gmail, Google Photos and Google Cloud AI APIs.

#opinions #alphabet #asics #floq #google #google alphabet #google quantum computing #google tensorflow #google tensorflow quantum #google tpu #google tpus #machine learning #quantum computer #quantum computing #quantum computing programming #quantum leap #sandbox #secret development #tensorflow #tpu #tpus