Build Deep high-quality website with Core Pro 5.1.8 and Theme 1.0.6
Code quản lý chi tiết sửa xóa đơn hàng
Code quản lý chi tiết sửa xóa đơn hàng
Migration.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOders_DetailTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('Oders_Detail', function (Blueprint $table) {
$table->integer('ID');
$table->string('Oderid');
$table->string('ProductId');
$table->integer('Quantity');
$table->string('VariantId');
$table->string('VariantTitle');
$table->string('Title');
$table->string('RequiresShipping');
$table->float('Price');
$table->float('DiscountedPrice');
$table->integer('Grams');
$table->string('AppliedDiscount');
$table->string('KeyID');
;
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('Oders_Detail');
}
}
Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Oders_detail extends Model
{
protected $table = 'Oders_Detail';
public $timestamps = false; // tắt tự tao cột updated_at và created_at
// const UPDATED_AT = null; sử dụng côt UPDATED thì mở dòng này
// const CREATED_AT = null; sử dụng côt CREATED thì mở dòng này
protected $fillable = [
'ID',
'Oderid',
'ProductId',
'Quantity',
'VariantId',
'VariantTitle',
'Title',
'RequiresShipping',
'Price',
'DiscountedPrice',
'Grams',
'AppliedDiscount',
'KeyID',
];
}
Create.php
@extends('layout.admin')
@section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Thêm mới oders_detail</h2>
</div>
<div class="pull-right">
<button type="button" class="btn btn-primary" onclick="$('#saveas').click();"><i class="fa fa-floppy-o"></i> Lưu
lại
</button>
<button type="button" class="btn btn-default" onclick="window.location.href=''">
<i class="fa fa-arrow-left"></i> Trở về
</button>
</div>
</div>
</div>
@if ($errors->any())
<div class="alert alert-danger">
<strong>Cảnh báo !</strong> Có 1 số lỗi xảy ra với bạn.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li></li>
@endforeach
</ul>
</div>
@endif
<form action="" method="POST">
@csrf
<div class="row">
<div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="ID" class="form-control" id="ID" name="ID" value="" type="text" > @if($errors->has('ID'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="Oderid" class="form-control" id="Oderid" name="Oderid" value="" type="text" > @if($errors->has('Oderid'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="ProductId" class="form-control" id="ProductId" name="ProductId" value="" type="text" > @if($errors->has('ProductId'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="Quantity" class="form-control" id="Quantity" name="Quantity" value="" type="text" > @if($errors->has('Quantity'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><textarea class="form-control" id="VariantId" name="VariantId" placeholder="VariantId" ></textarea> @if($errors->has('VariantId'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <script type='text/javascript'>
CKEDITOR.replace( 'VariantId',{
height : 150
});
</script><div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><textarea class="form-control" id="VariantTitle" name="VariantTitle" placeholder="VariantTitle" ></textarea> @if($errors->has('VariantTitle'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <script type='text/javascript'>
CKEDITOR.replace( 'VariantTitle',{
height : 150
});
</script><div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><textarea class="form-control" id="Title" name="Title" placeholder="Title" ></textarea> @if($errors->has('Title'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <script type='text/javascript'>
CKEDITOR.replace( 'Title',{
height : 150
});
</script> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong> <input type="radio" value="1" name="RequiresShipping"><label >Bật </label> <input type="radio" value="0" name="RequiresShipping"><label >Tắt </label> @if($errors->has('RequiresShipping'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="Price" class="form-control" id="Price" name="Price" value="" type="text" > @if($errors->has('Price'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="DiscountedPrice" class="form-control" id="DiscountedPrice" name="DiscountedPrice" value="" type="text" > @if($errors->has('DiscountedPrice'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="Grams" class="form-control" id="Grams" name="Grams" value="" type="text" > @if($errors->has('Grams'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><textarea class="form-control" id="AppliedDiscount" name="AppliedDiscount" placeholder="AppliedDiscount" ></textarea> @if($errors->has('AppliedDiscount'))
<em class="invalid-feedback">
</em>
@endif
</div></div> <script type='text/javascript'>
CKEDITOR.replace( 'AppliedDiscount',{
height : 150
});
</script><div class='col-xs-12 col-sm-12 col-md-12'>
<div class='form-group'>
<strong>:</strong><input placeholder="KeyID" class="form-control" id="KeyID" name="KeyID" value="" type="text" > @if($errors->has('KeyID'))
<em class="invalid-feedback">
</em>
@endif
</div></div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button class="btn btn-primary" style="width: 120px;" id="saveas" name="submit" type="submit" value="">
<i class="fa fa-floppy-o"></i> Lưu lại</button>
<button class="btn btn-primary" style="width: 120px;" name="submit" type="reset" value="">
<i class="fa fa-refresh" > </i> Nhập lại</button>
<button type="button" class="btn btn-primary" onclick="window.location.href=''">
<i class="fa fa-arrow-left"></i> Trở về
</button>
</div>
</div>
</form>
@endsection
Index.php
@extends('layout.admin')
@section('content')
<script>
function DeleteAll() {
if(confirm('Bạn có chắc muốn xóa những danh sách đang chọn ?')==true)
{
var url = '';
$('#form_main').attr('action', url);
$('#form_main').submit();
}
}
</script>
<div class="breadcrumbs-fixed panel-action">
<div class="row">
<div class="products-act">
<div class="col-md-4 col-md-offset-2">
<div class="left-action text-left clearfix">
<h2>Quản lý Oders_Detail</h2>
</div>
</div>
<div class="col-md-6">
<div class="right-action text-right">
<div class="btn-groups">
<button type="button" class="btn btn-primary" onclick="window.location.href=''"><i class="fa fa-plus"></i> Tạo mới
</button>
<button type="button" class="btn btn-danger" onclick="DeleteAll()"><i class="fa fa-trash-o"></i> Xóa chọn
</button>
<button type="button" class="btn btn-success"><i class="fa fa-print"></i> In Dữ liệu
</button>
</div>
</div>
</div>
</div>
</div>
</div>
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p></p>
</div>
@endif
<div class="products-content">
<div class="product-sear panel-sear" style='padding-top:30px'>
<form action="" method="get" id="frmTimkiem">
<input type="hidden" value="true" name="search">
<div class="form-group col-md-7 padd-0">
<input type="text" class="form-control" name="keyword" value="" placeholder="Nhập từ khóa hoặc tên cần tìm" id="product-search">
</div>
<div class="form-group col-md-5 ">
<div class="col-md-5 padd-0" style="margin-right: 10px;">
<select class="form-control search-option-3" name="column" >
<option value="" selected="selected">--Tất cả--</option>
<optgroup label="Chọn cột dữ liệu">
#searchcolumn#
</optgroup>
</select>
</div>
<button type="submit" class="btn btn-primary btn-large btn-ssup"><i class="fa fa-search"></i> Tìm kiếm
</button>
</div>
</form>
</div>
<div class="product-main-body">
<div class="box-body">
<style> table a{color:black} </style><form action="" method="post" id="form_main">
<table class=" table table-striped table-bordered table-hover ">
<tr>
<th><input type="checkbox" class="checkbox chkAll" onclick="$('input:checkbox').not(this).prop('checked', this.checked); " style='display:block'></th>
<th>ID</th>
<th>Oderid</th>
<th>ProductId</th>
<th>Quantity</th>
<th>VariantId</th>
<th>VariantTitle</th>
<th width="280px">Hành động</th>
</tr>
@foreach ( $oders_details as $item )
<tr>
<td><input type="checkbox" name="id_check[]" value="" class="checkbox chk" style='display:block'></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<form action="" method="POST">
<a class="btn btn-info" href=""><i class="fa fa-eye"></i> Xem</a>
<a class="btn btn-primary" href=""> <i class="fa fa-edit"></i> Sửa</a>
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger"><i class="fa fa-trash-o"></i> Xóa</button>
</form>
</td>
</tr>
@endforeach
</table>
</form>
</div>
<div class="alert alert-info summany-info clearfix" role="alert">
<div class="sm-info pull-left padd-0"> Tổng SL/Trang:
<span>/</span> </div>
<div class="pull-right ajax-pagination"> {!! $oders_details->links() !!}
</div>
</div>
</div>
</div>
@endsection
0 Nhận xét
Hãy trở thành người đầu tiên viết chia sẽ cảm nghĩ của mình bên dưới nhé!
Thêm Bình luận