Search
 
SCRIPT & CODE EXAMPLE
 

PHP

list.blade.php

@extends('layouts.app') @section('content')
<div class="container">
	<div class="row">
		<div class="col-12 text-center pt-5">
			<h1 class="display-one m-5">PHP Laravel Project - CRUD</h1>
			<div class="text-left"><a href="product/create" class="btn btn-outline-primary">Add new
				product</a></div>

			<table class="table mt-3  text-left">
				<thead>
					<tr>
						<th scope="col">Product Title</th>
						<th scope="col" class="pr-5">Price (USD)</th>
						<th scope="col">Short Notes</th>
						<th scope="col">Action</th>
					</tr>
				</thead>
				<tbody>
					@forelse($products as $product)
					<tr>
						<td>{!! $product->title !!}</td>
						<td class="pr-5 text-right">{!! $product->price !!}</td>
						<td>{!! $product->short_notes !!}</td>
						<td><a href="product/{!! $product->id !!}/edit"
							class="btn btn-outline-primary">Edit</a>
							<button type="button" class="btn btn-outline-danger ml-1"
								onClick='showModel({!! $product->id !!})'>Delete</button></td>
					</tr>
					@empty
					<tr>
						<td colspan="3">No products found</td>
					</tr>
					@endforelse
				</tbody>
			</table>
		</div>
	</div>
</div>


<div class="modal fade" id="deleteConfirmationModel" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-body">Are you sure to delete this record?</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" onClick="dismissModel()">Cancel</button>
				<form id="delete-frm" class="" action="" method="POST">
                    @method('DELETE')
                    @csrf
                    <button class="btn btn-danger">Delete</button>
                </form>
			</div>
		</div>
	</div>
</div>

<script>
function showModel(id) {
	var frmDelete = document.getElementById("delete-frm");
	frmDelete.action = 'product/'+id;
	var confirmationModal = document.getElementById("deleteConfirmationModel");
	confirmationModal.style.display = 'block';
	confirmationModal.classList.remove('fade');
	confirmationModal.classList.add('show');
}

function dismissModel() {
	var confirmationModal = document.getElementById("deleteConfirmationModel");
	confirmationModal.style.display = 'none';
	confirmationModal.classList.remove('show');
	confirmationModal.classList.add('fade');
}
</script>
@endsection
Comment

PREVIOUS NEXT
Code Example
Php :: Save custom input field value into cart item 
Php :: Stripe Test - Laravel 
Php :: php on page query 
Php :: laravel view not created using foreign keys 
Php :: Number in English Words (Indian format) php 
Php :: big database file into database php 
Php :: Stopping On First Validation Failure 
Php :: verifier la version de php sur mon ordi 
Php :: laravel gigapay list invoice 
Php :: ganti url phpmyadmin 
Php :: gan_sql 
Php :: laravel gigapay delete employee 
Php :: php random string for filename 
Php :: how to check if coupons are valid or not magento 2 
Php :: dot after each character php 
Php :: laravel-filemanager not working 
Php :: recaptcha v3 laravel 8 
Php :: get table row data onclick 
Php :: Generate slug 
Php :: cara looping abjad with array 
Php :: Laravel Customizing Missing Model Behavior 
Php :: laravel csrf token or protection or laravel form 
Php :: drupal 7 hook_node_insert 
Php :: cashier mollie 
Php :: HASHING in php double scripting 
Php :: array_map with user functions php and parameter php 
Php :: white labeling wordpress divi 
Php :: Rewrite .php file without .php extension with .htaccess ULTIMATE SOLUTION 
Php :: laravel 8 ui auth 
Php :: Access app.php values laravel 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =