Published
Edited
Jan 17, 2022
Insert cell
# Encrypt and Decrypt Id in Laravel
Insert cell
<table class="table">
<thead>
<tr>
<th>S.no</th>
<th>Order / Product No.</th>
<th>Product Name</th>
<th>Category</th>
<th>Product Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach($productList as $key => $data)
<tr>
<td>{{ $key+1 }}</td>
<td>{{$data->product_no}}</td>
<td>{{$data->name}}</td>
<td>{{$data->CategoryData->name}}</td>
<td>{{$data->description}}</td>
<td><a href="{{route('view.product',[$data['id'],$data['product_no']])}}">View</a>
@php $prodID= Crypt::encrypt($data->id); @endphp
<!--Encrypt ID and store as $prodID-->
<a href="{{route('edit.product',$prodID)}}">Edit</a>
</td>
</tr>
</tbody>
@endforeach
</table>
Insert cell
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use App\Product;
class ProductController extends Controller
{
public function editProduct($id){
$prodID = Crypt::decrypt($id);
$Data = Product::find($prodID);
dd($Data);
return view('product.view',compact('Data'));
}
}
Insert cell
Type TeX, then Shift-Enter.

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more