Bài 08: Hiển thị danh sách sản phẩm ,Hiển thị form chỉnh Sửa sản phẩm

Bài 08: Hiển thị danh sách sản phẩm ,Hiển thị form chỉnh Sửa sản phẩm

 

Hiển thị danh sách sản phẩm

-    Vào AdminProductController.php
<?php

namespace App\Http\Controllers;

use App\Category;
use App\Components\Recusive;
use App\Product;
use App\ProductImage;
use App\ProductTag;
use App\Tag;
use App\Traits\StorageImageTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Storage;

class AdminProductController extends Controller
{
use StorageImageTrait;
private $category;
private $product;
private $productImage;
private $tag;
private $productTag;
public function __construct(Category $category,Product $product ,ProductImage $productImage,
Tag $tag,ProductTag $productTag)
{
$this->category = $category;
$this->product = $product;
$this->productImage = $productImage;
$this->tag = $tag;
$this->productTag = $productTag;
}

public function index()
{
$products = $this->product->latest()->paginate(5);
return view('admin.product.index', compact('products'));
}
public function create()
{
$htmlOption = $this->getCategory($parentId='');
return view('admin.product.add',compact('htmlOption'));
}
public function getCategory($parentId)
{
$data = $this->category->all();
$recusive = new Recusive($data);
$htmlOption = $recusive->categoryRecusive($parentId);
return $htmlOption;
}
public function store(Request $request)
{
try {
$dataProductCreate = [
'name'=>$request->name,
'price' =>$request->price,
'content' => $request->contents,
'user_id' => auth()->id(),
'category_id'=>$request->category_id
];
$dataUploadFeatureImage = $this->storageTraitUpload($request, 'feature_image_path','product');
if (!empty($dataUploadFeatureImage)){
$dataProductCreate['feature_image_name']=$dataUploadFeatureImage['file_name'];
$dataProductCreate['feature_image_path']=$dataUploadFeatureImage['file_path'];
}
$product = $this->product->create($dataProductCreate);

//Insert data -> product_images
if ( $request->hasFile('image_path') ) {
foreach ($request->image_path as $fileItem){
$dataProductImageDetall = $this->storageTraitUploadMutiple($fileItem,'`product_images');
$product->images()->create([
'image_path'=> $dataProductImageDetall['file_path'],
'image_name'=> $dataProductImageDetall['file_name']
]);
}
}
//Insert tags -> product
if (!empty($request->tags)){
foreach ($request->tags as $tagItem){
//Insert to Tags
$tagInstance = $this->tag->firstOrCreate(['name' => $tagItem]);
$tagIds[] = $tagInstance->id;
}
}
$product->tags()->attach($tagIds);
DB::commit();
return redirect()->route('product.index');
} catch (\Exception $exception){
DB::rollBack();
log::error('Message: ' .$exception->getMessage().' --- Line : '.$exception->getLine());
}
}
}
 -    Vào Views => admin => product => add.blade.php

<!-- Stored in resources/views/child.blade.php -->

@extends('layouts.admin')

@section('title')
<title>Add Product</title>
@endsection

@section('css')
<link rel="stylesheet" href="{{ asset('admins/product/index/list.css') }}">
@endsection

@section('js')

@endsection

@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
@include('partials.content-header',['name'=>'product', 'key'=>'List']);
<!-- /.content-header -->

<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<a href="{{ route('product.create') }}" class="btn btn-success float-right mr-2">add</a>
</div>
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Tên sn phm</th>
<th scope="col">Giá</th>
<th scope="col">Hình nh</th>
<th scope="col">Danh mc</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>

@foreach($products as $productItem)

<tr>
<th scope="row">{{ $productItem->id }}</th>
<td>{{ $productItem->name}} </td>
<td>{{ $productItem->price }}</td>
<td>
<img class="product_image" src="{{$productItem->feature_image_path}}" alt="">
</td>
<td>{{ $productItem->category->name }}</td>
<td>
<a href=""
class="btn btn-default">Edit</a>
<a href=""
class="btn btn-danger">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="col-md-12">
{{ $products->links() }}
</div>

</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</div>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@endsection
-    Vào Public => admins => tạo foder index => Tạo file list.css
.product_image{
width: 150px;
height: 100px;
object-fit: cover;
}
-    Vào Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
protected $guarded = [];
public function images(){
return $this->hasMany(ProductImage::class, 'product_id');
}
public function tags(){
return $this->belongsToMany(Tag::class,'product_tags','product_id','tag_id')
->withTimestamps();
}
public function category(){
return $this->belongsTo(Category::class, 'category_id');
}
}

Chỉnh Sửa  sản phẩm

-    Vào web.php
<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/admin', 'AdminController@loginAdmin');
Route::post('/admin', 'AdminController@postloginAdmin');

Route::get('/home', function () {
return view('home');
});

Route::prefix('admin')->group(function () {
//category
Route::prefix('categories')->group(function () {
Route::get('/',[
'as'=> 'categories.index',
'uses' => 'CategoryController@index'
]);

Route::get('/create',[
'as'=> 'categories.create',
'uses' => 'CategoryController@create'
]);
Route::post('/store',[
'as'=> 'categories.store',
'uses' => 'CategoryController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'categories.edit',
'uses' => 'CategoryController@edit'
]);
Route::post('/update/{id}',[
'as'=> 'categories.update',
'uses' => 'CategoryController@update'
]);
Route::get('/delete/{id}',[
'as'=> 'categories.delete',
'uses' => 'CategoryController@delete'
]);
});
//menu
Route::prefix('menus')->group(function () {
Route::get('/',[
'as'=> 'menus.index',
'uses' => 'MenuController@index'
]);
Route::get('/create',[
'as'=> 'menus.create',
'uses' => 'MenuController@create'
]);
Route::post('/store',[
'as'=> 'menus.store',
'uses' => 'MenuController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'menus.edit',
'uses' => 'MenuController@edit'
]);
Route::post('/update/{id}',[
'as'=> 'menus.update',
'uses' => 'MenuController@update'
]);
Route::get('/delete/{id}',[
'as'=> 'menus.delete',
'uses' => 'MenuController@delete'
]);
});
//Product
Route::prefix('product')->group(function () {
Route::get('/',[
'as'=> 'product.index',
'uses' => 'AdminProductController@index'
]);
Route::get('/create',[
'as'=> 'product.create',
'uses' => 'AdminProductController@create'
]);
Route::post('/store',[
'as'=> 'product.store',
'uses' => 'AdminProductController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'product.edit',
'uses' => 'AdminProductController@edit'
]);
})
;
});


-    Vào AdminProductController.php
<?php

namespace App\Http\Controllers;

use App\Category;
use App\Components\Recusive;
use App\Product;
use App\ProductImage;
use App\ProductTag;
use App\Tag;
use App\Traits\StorageImageTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Storage;

class AdminProductController extends Controller
{
use StorageImageTrait;
private $category;
private $product;
private $productImage;
private $tag;
private $productTag;
public function __construct(Category $category,Product $product ,ProductImage $productImage,
Tag $tag,ProductTag $productTag)
{
$this->category = $category;
$this->product = $product;
$this->productImage = $productImage;
$this->tag = $tag;
$this->productTag = $productTag;
}

public function index()
{
$products = $this->product->latest()->paginate(5);
return view('admin.product.index', compact('products'));
}
public function create()
{
$htmlOption = $this->getCategory($parentId='');
return view('admin.product.add',compact('htmlOption'));
}
public function getCategory($parentId)
{
$data = $this->category->all();
$recusive = new Recusive($data);
$htmlOption = $recusive->categoryRecusive($parentId);
return $htmlOption;
}
public function store(Request $request)
{
try {
$dataProductCreate = [
'name'=>$request->name,
'price' =>$request->price,
'content' => $request->contents,
'user_id' => auth()->id(),
'category_id'=>$request->category_id
];
$dataUploadFeatureImage = $this->storageTraitUpload($request, 'feature_image_path','product');
if (!empty($dataUploadFeatureImage)){
$dataProductCreate['feature_image_name']=$dataUploadFeatureImage['file_name'];
$dataProductCreate['feature_image_path']=$dataUploadFeatureImage['file_path'];
}
$product = $this->product->create($dataProductCreate);

//Insert data -> product_images
if ( $request->hasFile('image_path') ) {
foreach ($request->image_path as $fileItem){
$dataProductImageDetall = $this->storageTraitUploadMutiple($fileItem,'`product_images');
$product->images()->create([
'image_path'=> $dataProductImageDetall['file_path'],
'image_name'=> $dataProductImageDetall['file_name']
]);
}
}
//Insert tags -> product
if (!empty($request->tags)){
foreach ($request->tags as $tagItem){
//Insert to Tags
$tagInstance = $this->tag->firstOrCreate(['name' => $tagItem]);
$tagIds[] = $tagInstance->id;
}
}
$product->tags()->attach($tagIds);
DB::commit();
return redirect()->route('product.index');
} catch (\Exception $exception){
DB::rollBack();
log::error('Message: ' .$exception->getMessage().' --- Line : '.$exception->getLine());
}
}
public function edit($id){
$product = $this->product->find($id);
$htmlOption = $this->getCategory($product->category_id);
return view('admin.product.edit',compact('htmlOption', 'product'));
}
}
-    Vào resource => admin => product => index.balde.php
<!-- Stored in resources/views/child.blade.php -->

@extends('layouts.admin')

@section('title')
<title>Add Product</title>
@endsection

@section('css')
<link rel="stylesheet" href="{{ asset('admins/product/index/list.css') }}">
@endsection

@section('js')

@endsection

@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
@include('partials.content-header',['name'=>'product', 'key'=>'List']);
<!-- /.content-header -->

<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<a href="{{ route('product.create') }}" class="btn btn-success float-right mr-2">add</a>
</div>
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Tên sn phm</th>
<th scope="col">Giá</th>
<th scope="col">Hình nh</th>
<th scope="col">Danh mc</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>

@foreach($products as $productItem)

<tr>
<th scope="row">{{ $productItem->id }}</th>
<td>{{ $productItem->name}} </td>
<td>{{ number_format($productItem->price) }}</td>
<td>
<img class="product_image" src="{{$productItem->feature_image_path}}" alt="">
</td>
<td>{{ optional($productItem->category)->name }}</td>
<td>
<a href="{{ route('product.edit', ['id'=>$productItem->id]) }}"
class="btn btn-default">Edit</a>
<a href=""
class="btn btn-danger">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="col-md-12">
{{ $products->links() }}
</div>

</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</div>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@endsection
-    Vào resource => admin => product => Tạo file edit.balde.php
<!-- Stored in resources/views/child.blade.php -->

@extends('layouts.admin')

@section('title')
<title>Add product</title>
@endsection

@section('css')
<link href="{{ asset('vendors/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('admins/product/add/add.css') }}" rel="stylesheet" />
@endsection

@section('content')
<div class="content-wrapper">
@include('partials.content-header',['name'=>'product', 'key'=>'Edit']);
<form action="{{ route("product.store") }}" method="post" enctype="multipart/form-data">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">

@csrf
<div class="form-group">
<label>Tên sn phm</label>
<input class="form-control"
name="name"
placeholder="Nhp tên sn phm"
value="{{$product->name}}"
>
</div>

<div class="form-group">
<label>Tên giá sn phm</label>
<input type="text"
class="form-control"
name="price"
placeholder="Nhp giá sn phm"
value="{{$product->price}}"
>
</div>

<div class="form-group">
<label>nh đi din</label>
<input type="file"
class="form-control-file"
name="feature_image_path"
>
<div class="col-md-3 feature_image_container">
<div class="row">
<img class="feature_image" src="{{$product->feature_image_path}}" alt="">
</div>
</div>
</div>

<div class="form-group">
<label>nh chi tiết</label>
<input type="file"
multiple
class="form-control-file"
name="image_path[]"
>
<div class="col-md-12 container_image_detail">
<div class="row">
@foreach($product->productImages as $productImageItem)
<div class="col-md-3">
<img class="image_detail_product" src="{{$productImageItem->image_path}}" alt="">
</div>
@endforeach
</div>
</div>
</div>

<div class="form-group">
<label>Chn danh mc</label>
<select class="form-control select2_init"
name="category_id">
<option value="">Chn danh mc</option>
{!! $htmlOption !!}}
</select>
</div>

<div class="form-group">
<label>Nhp tag cho sn phm</label>
<select name="tags[]" class="form-control tags_select_choose" multiple="multiple">
@foreach($product->tags as $tagItem)
<option value="{{$tagItem->name}}" selected>{{$tagItem->name}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label >Nhp ni dung</label>
<textarea name="contents" class="form-control tinymce_editor_init" rows="10">
{{$product->content}}
</textarea>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

@section('js')
<script src="{{ asset('vendors/select2/select2.min.js') }}"></script>
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script src="{{ asset('admins/product/add/add.js') }}"></script>
@endsection
-    Vào Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
protected $guarded = [];
public function images(){
return $this->hasMany(ProductImage::class, 'product_id');
}
public function tags(){
return $this->belongsToMany(Tag::class,'product_tags','product_id','tag_id')
->withTimestamps();
}
public function category(){
return $this->belongsTo(Category::class, 'category_id');
}
public function productImages(){
return $this->hasMany(ProductImage::class,'product_id');
}
}
-    Vào public=> admins => product => add.css
.select2-selection__choice{
background-color: #0e2401 !important;
}
.image_detail_product, .feature_image{
width: 100%;
height: 130px;
object-fit: cover;
}
.container_image_detail,.feature_image_container{
margin-top: 20px;
}

Cập nhật sản phẩm

-    Vào web.php
<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/admin', 'AdminController@loginAdmin');
Route::post('/admin', 'AdminController@postloginAdmin');

Route::get('/home', function () {
return view('home');
});

Route::prefix('admin')->group(function () {
//category
Route::prefix('categories')->group(function () {
Route::get('/',[
'as'=> 'categories.index',
'uses' => 'CategoryController@index'
]);

Route::get('/create',[
'as'=> 'categories.create',
'uses' => 'CategoryController@create'
]);
Route::post('/store',[
'as'=> 'categories.store',
'uses' => 'CategoryController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'categories.edit',
'uses' => 'CategoryController@edit'
]);
Route::post('/update/{id}',[
'as'=> 'categories.update',
'uses' => 'CategoryController@update'
]);
Route::get('/delete/{id}',[
'as'=> 'categories.delete',
'uses' => 'CategoryController@delete'
]);
});
//menu
Route::prefix('menus')->group(function () {
Route::get('/',[
'as'=> 'menus.index',
'uses' => 'MenuController@index'
]);
Route::get('/create',[
'as'=> 'menus.create',
'uses' => 'MenuController@create'
]);
Route::post('/store',[
'as'=> 'menus.store',
'uses' => 'MenuController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'menus.edit',
'uses' => 'MenuController@edit'
]);
Route::post('/update/{id}',[
'as'=> 'menus.update',
'uses' => 'MenuController@update'
]);
Route::get('/delete/{id}',[
'as'=> 'menus.delete',
'uses' => 'MenuController@delete'
]);
});
//Product
Route::prefix('product')->group(function () {
Route::get('/',[
'as'=> 'product.index',
'uses' => 'AdminProductController@index'
]);
Route::get('/create',[
'as'=> 'product.create',
'uses' => 'AdminProductController@create'
]);
Route::post('/store',[
'as'=> 'product.store',
'uses' => 'AdminProductController@store'
]);
Route::get('/edit/{id}',[
'as'=> 'product.edit',
'uses' => 'AdminProductController@edit'
]);
Route::post('/update/{id}',[
'as'=> 'product.update',
'uses' => 'AdminProductController@update'
])
;
});
});


-    Vào AdminProductController.php
<?php

namespace App\Http\Controllers;

use App\Category;
use App\Components\Recusive;
use App\Product;
use App\ProductImage;
use App\ProductTag;
use App\Tag;
use App\Traits\StorageImageTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Storage;

class AdminProductController extends Controller
{
use StorageImageTrait;
private $category;
private $product;
private $productImage;
private $tag;
private $productTag;
public function __construct(Category $category,Product $product ,ProductImage $productImage,
Tag $tag,ProductTag $productTag)
{
$this->category = $category;
$this->product = $product;
$this->productImage = $productImage;
$this->tag = $tag;
$this->productTag = $productTag;
}

public function index()
{
$products = $this->product->latest()->paginate(5);
return view('admin.product.index', compact('products'));
}
public function create()
{
$htmlOption = $this->getCategory($parentId='');
return view('admin.product.add',compact('htmlOption'));
}
public function getCategory($parentId)
{
$data = $this->category->all();
$recusive = new Recusive($data);
$htmlOption = $recusive->categoryRecusive($parentId);
return $htmlOption;
}
public function store(Request $request)
{
try {
DB::beginTransaction();
$dataProductCreate = [
'name'=>$request->name,
'price' =>$request->price,
'content' => $request->contents,
'user_id' => auth()->id(),
'category_id'=>$request->category_id
];
$dataUploadFeatureImage = $this->storageTraitUpload($request, 'feature_image_path','product');
if (!empty($dataUploadFeatureImage)){
$dataProductCreate['feature_image_name']=$dataUploadFeatureImage['file_name'];
$dataProductCreate['feature_image_path']=$dataUploadFeatureImage['file_path'];
}
$product = $this->product->create($dataProductCreate);

//Insert data -> product_images
if ( $request->hasFile('image_path') ) {
foreach ($request->image_path as $fileItem){
$dataProductImageDetall = $this->storageTraitUploadMutiple($fileItem,'`product_images');
$product->images()->create([
'image_path'=> $dataProductImageDetall['file_path'],
'image_name'=> $dataProductImageDetall['file_name']
]);
}
}
//Insert tags -> product
if (!empty($request->tags)){
foreach ($request->tags as $tagItem){
//Insert to Tags
$tagInstance = $this->tag->firstOrCreate(['name' => $tagItem]);
$tagIds[] = $tagInstance->id;
}
}
$product->tags()->attach($tagIds);
DB::commit();
return redirect()->route('product.index');
} catch (\Exception $exception){
DB::rollBack();
log::error('Message: ' .$exception->getMessage().' --- Line : '.$exception->getLine());
}
}
public function edit($id){
$product = $this->product->find($id);
$htmlOption = $this->getCategory($product->category_id);
return view('admin.product.edit',compact('htmlOption', 'product'));
}
public function update(Request $request,$id)
{
try {
DB::beginTransaction();
$dataProductUpdate = [
'name'=>$request->name,
'price' =>$request->price,
'content' => $request->contents,
'user_id' => auth()->id(),
'category_id'=>$request->category_id
];
$dataUploadFeatureImage = $this->storageTraitUpload($request, 'feature_image_path','product');
if (!empty($dataUploadFeatureImage)){
$dataProductUpdate['feature_image_name']=$dataUploadFeatureImage['file_name'];
$dataProductUpdate['feature_image_path']=$dataUploadFeatureImage['file_path'];
}
$this->product->find($id)->update($dataProductUpdate);
$product = $this->product->find($id);

//Insert data -> product_images
if ( $request->hasFile('image_path') ) {
$this->productImage->where('product_id',$id)->delete();
foreach ($request->image_path as $fileItem){
$dataProductImageDetall = $this->storageTraitUploadMutiple($fileItem,'`product_images');
$product->images()->create([
'image_path'=> $dataProductImageDetall['file_path'],
'image_name'=> $dataProductImageDetall['file_name']
]);
}
}
//Insert tags -> product
if (!empty($request->tags)){
foreach ($request->tags as $tagItem){
//Insert to Tags
$tagInstance = $this->tag->firstOrCreate(['name' => $tagItem]);
$tagIds[] = $tagInstance->id;
}
}
$product->tags()->sync($tagIds);
DB::commit();
return redirect()->route('product.index');
} catch (\Exception $exception){
DB::rollBack();
log::error('Message: ' .$exception->getMessage().' --- Line : '.$exception->getLine());
}
}
}
-    Vào resource => admin => product => Tạo file edit.balde.php
<!-- Stored in resources/views/child.blade.php -->

@extends('layouts.admin')

@section('title')
<title>Add product</title>
@endsection

@section('css')
<link href="{{ asset('vendors/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('admins/product/add/add.css') }}" rel="stylesheet" />
@endsection

@section('content')
<div class="content-wrapper">
@include('partials.content-header',['name'=>'product', 'key'=>'Edit']);
<form action="{{ route("product.update",['id'=>$product->id]) }}" method="post" enctype="multipart/form-data">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">

@csrf
<div class="form-group">
<label>Tên sn phm</label>
<input class="form-control"
name="name"
placeholder="Nhp tên sn phm"
value="{{$product->name}}"
>
</div>

<div class="form-group">
<label>Tên giá sn phm</label>
<input type="text"
class="form-control"
name="price"
placeholder="Nhp giá sn phm"
value="{{$product->price}}"
>
</div>

<div class="form-group">
<label>nh đi din</label>
<input type="file"
class="form-control-file"
name="feature_image_path"
>
<div class="col-md-3 feature_image_container">
<div class="row">
<img class="feature_image" src="{{$product->feature_image_path}}" alt="">
</div>
</div>
</div>

<div class="form-group">
<label>nh chi tiết</label>
<input type="file"
multiple
class="form-control-file"
name="image_path[]"
>
<div class="col-md-12 container_image_detail">
<div class="row">
@foreach($product->productImages as $productImageItem)
<div class="col-md-3">
<img class="image_detail_product" src="{{$productImageItem->image_path}}" alt="">
</div>
@endforeach
</div>
</div>
</div>

<div class="form-group">
<label>Chn danh mc</label>
<select class="form-control select2_init"
name="category_id">
<option value="">Chn danh mc</option>
{!! $htmlOption !!}}
</select>
</div>

<div class="form-group">
<label>Nhp tag cho sn phm</label>
<select name="tags[]" class="form-control tags_select_choose" multiple="multiple">
@foreach($product->tags as $tagItem)
<option value="{{$tagItem->name}}" selected>{{$tagItem->name}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label >Nhp ni dung</label>
<textarea name="contents" class="form-control tinymce_editor_init" rows="10">
{{$product->content}}
</textarea>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

@section('js')
<script src="{{ asset('vendors/select2/select2.min.js') }}"></script>
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script src="{{ asset('admins/product/add/add.js') }}"></script>
@endsection





Đăng nhận xét

0 Nhận xét

myadcash