😂Bài 246 - Lập trình web bán hàng Laravel - Phân cấp danh mục đệ quy, Recursive (ok)

C:\xampp8\htdocs\lvasample\database\migrations\2019_06_17_161852_create_tbl_category_product.php

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTblCategoryProduct extends Migration {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::create('tbl_category_product', function (Blueprint $table) {
      $table->Increments('category_id');
      $table->string('category_name');
      $table->text('category_desc');
      $table->integer('category_status');
      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    Schema::dropIfExists('tbl_category_product');
  }
}

C:\xampp8\htdocs\lvasample\app\Models\CategoryProductModel.php

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CategoryProductModel extends Model
{
  public $timestamps = false; //set time to false
  protected $fillable = [
    'meta_keywords', 
    'category_name', 
    'slug_category_product', 
    'category_desc', 
    'category_status', 
    'category_parent', 
    'category_order'
  ];
  protected $primaryKey = 'category_id';
  protected $table = 'tbl_category_product';
  public static function recursive($categories, $parents = 0, $level = 1, &$listCategory)
  {
    if(count($categories) > 0) {
      foreach ($categories as $key => $value) {
        if ($value->category_parent == $parents) {
          $value->level = $level;
          $listCategory[] = $value;
          unset($categories[$key]);
          $parent = $value->category_id;
          self::recursive($categories, $parent, $level + 1, $listCategory);
        }
      }
    }
  }
}

app/Http/Controllers/CategoryProduct.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\CategoryProductModel;
use App\Http\Requests;
class CategoryProduct extends Controller
{
  public function add_category_product()
  {
    $category = $this->getCategoriesProduct();
    return view('admin.add_category_product')->with(compact('category'));
  }
  public function getCategoriesProduct()
  {
    $categories = CategoryProductModel::where('category_status', 0)->get();
    $listCategory = [];
    CategoryProductModel::recursive($categories, $parents = 0, $level = 1, $listCategory);
    return $listCategory;
  }
}

C:\xampp8\htdocs\lvasample\routes\web.php

<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\CategoryProduct;
/*
|--------------------------------------------------------------------------
| 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('/', function () {
  return view('welcome');
});
Route::get('/add-category-product',[CategoryProduct::class,'add_category_product']);p

C:\xampp8\htdocs\lvasample\resources\views\admin\add_category_product.blade.php

<!DOCTYPE html>
<head>
  <title>Dashboard</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css">
</head>
<body>
  <section class="container">
    <div class="row">
      <div class="col-lg-12">
        <section class="panel">
          <header class="panel-heading h2 mt-5">
            Thêm danh mục sản phẩm
          </header>
          <div class="panel-body">
            <div class="position-center">
              <form role="form" action="#" method="post">
                <div class="form-group">
                  <label class="h3">Thuộc danh mục</label>
                  <select name="category_parent" class="form-control input-sm m-bot15">
                    <option value="0">Danh mục cha</option>
                    @foreach($category as $key => $value)
                    <option value="{{$value->category_id}}">
                      @php
                      $str = "";
                      for($i = 0; $i < $value->level;$i++) {
                        echo $str;
                        $str = "😒";
                        }
                        @endphp
                        {{$value->category_name}}
                    </option>
                    @endforeach
                  </select>
                </div>
              </form>
            </div>
          </div>
        </section>
      </div>
    </div>
  </section>
</body>
</html>
$listCategory = 👇
array (
  0 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 1,
      'meta_keywords' => 'Tay cầm chơi game',
      'category_name' => 'Tay cầm chơi game',
      'slug_category_product' => 'tay-cam-choi-game',
      'category_desc' => 'Tay cầm chơi game',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 8,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 1,
      'meta_keywords' => 'Tay cầm chơi game',
      'category_name' => 'Tay cầm chơi game',
      'slug_category_product' => 'tay-cam-choi-game',
      'category_desc' => 'Tay cầm chơi game',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 8,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  1 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 2,
      'meta_keywords' => 'may chơi game,may choi game,máy game,game chinh hãng,máy chơi game chính hãng',
      'category_name' => 'Máy chơi game',
      'slug_category_product' => 'may-choi-game',
      'category_desc' => 'Máy chơi game chính hãng nhập từ Mỹ,Úc,Nhật bản',
      'category_parent' => 1,
      'category_status' => 0,
      'category_order' => 7,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 2,
      'meta_keywords' => 'may chơi game,may choi game,máy game,game chinh hãng,máy chơi game chính hãng',
      'category_name' => 'Máy chơi game',
      'slug_category_product' => 'may-choi-game',
      'category_desc' => 'Máy chơi game chính hãng nhập từ Mỹ,Úc,Nhật bản',
      'category_parent' => 1,
      'category_status' => 0,
      'category_order' => 7,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  2 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 3,
      'meta_keywords' => 'Quần áo cho nam,quan ao nam,mua quan nam,bán quần nam',
      'category_name' => 'Quần áo cho nam',
      'slug_category_product' => 'quan-ao-cho-nam',
      'category_desc' => 'Quần áo cho nam nhập từ China ,Hàn quốc,việt nam',
      'category_parent' => 2,
      'category_status' => 0,
      'category_order' => 5,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 3,
    ),
     'original' => 
    array (
      'category_id' => 3,
      'meta_keywords' => 'Quần áo cho nam,quan ao nam,mua quan nam,bán quần nam',
      'category_name' => 'Quần áo cho nam',
      'slug_category_product' => 'quan-ao-cho-nam',
      'category_desc' => 'Quần áo cho nam nhập từ China ,Hàn quốc,việt nam',
      'category_parent' => 2,
      'category_status' => 0,
      'category_order' => 5,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  3 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 4,
      'meta_keywords' => 'Quần áo cho nữ',
      'category_name' => 'Quần áo cho nữ',
      'slug_category_product' => 'quan-ao-cho-nu',
      'category_desc' => 'Quần áo cho nữ được nhập từ hàn quốc và nhật bản',
      'category_parent' => 3,
      'category_status' => 0,
      'category_order' => 6,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 4,
    ),
     'original' => 
    array (
      'category_id' => 4,
      'meta_keywords' => 'Quần áo cho nữ',
      'category_name' => 'Quần áo cho nữ',
      'slug_category_product' => 'quan-ao-cho-nu',
      'category_desc' => 'Quần áo cho nữ được nhập từ hàn quốc và nhật bản',
      'category_parent' => 3,
      'category_status' => 0,
      'category_order' => 6,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  4 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 5,
      'meta_keywords' => 'sach kinh te,ban sach kinh te,bán sách kinh tế ,sách dạy làm giàu',
      'category_name' => 'Sách kinh tế',
      'slug_category_product' => 'sach-kinh-te',
      'category_desc' => 'Bán sách kinh tế dạy đầu tư chính khoáng,đầu tư bất động sản',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 2,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 5,
      'meta_keywords' => 'sach kinh te,ban sach kinh te,bán sách kinh tế ,sách dạy làm giàu',
      'category_name' => 'Sách kinh tế',
      'slug_category_product' => 'sach-kinh-te',
      'category_desc' => 'Bán sách kinh tế dạy đầu tư chính khoáng,đầu tư bất động sản',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 2,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  5 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 6,
      'meta_keywords' => 'Sách ngôn tình,sach ngon tinh,sach ngon tinh,sách dạy ngôn tình,sach ngon tinh chính thống',
      'category_name' => 'Sách ngôn tình',
      'slug_category_product' => 'sach-ngon-tinh',
      'category_desc' => 'Sách ngôn tình yêu đậm tính nhân văn và giáo dục',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 6,
      'meta_keywords' => 'Sách ngôn tình,sach ngon tinh,sach ngon tinh,sách dạy ngôn tình,sach ngon tinh chính thống',
      'category_name' => 'Sách ngôn tình',
      'slug_category_product' => 'sach-ngon-tinh',
      'category_desc' => 'Sách ngôn tình yêu đậm tính nhân văn và giáo dục',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  6 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 7,
      'meta_keywords' => 'ba lo cho chó,ba lo cho chó,ba lo chó,ba lo cho chó mèo',
      'category_name' => 'Ba lô thú cưng',
      'slug_category_product' => 'ba-lo-thu-cưng',
      'category_desc' => 'Bán ba lô cho thú cưng nhập khẩu uy tín chất lượng',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 4,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 7,
      'meta_keywords' => 'ba lo cho chó,ba lo cho chó,ba lo chó,ba lo cho chó mèo',
      'category_name' => 'Ba lô thú cưng',
      'slug_category_product' => 'ba-lo-thu-cưng',
      'category_desc' => 'Bán ba lô cho thú cưng nhập khẩu uy tín chất lượng',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 4,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  7 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 8,
      'meta_keywords' => 'Thức ăn thú cưng,thuc an cho thu cung,thuc an thu cung,thu cung',
      'category_name' => 'Thức ăn cho thú cưng',
      'slug_category_product' => 'thuc-an-cho-thu-cung',
      'category_desc' => 'Bán thức ăn ngon chính hãng cho thú cưng của bạn',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 3,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 8,
      'meta_keywords' => 'Thức ăn thú cưng,thuc an cho thu cung,thuc an thu cung,thu cung',
      'category_name' => 'Thức ăn cho thú cưng',
      'slug_category_product' => 'thuc-an-cho-thu-cung',
      'category_desc' => 'Bán thức ăn ngon chính hãng cho thú cưng của bạn',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 3,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  8 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 14,
      'meta_keywords' => 'Thức ăn cho mèo,thuc an cho meo,meo thuc an,thức ăn mèo con',
      'category_name' => 'Thức ăn cho mèo',
      'slug_category_product' => 'thuc-an-cho-meo',
      'category_desc' => 'Thức ăn cho mèo',
      'category_parent' => 8,
      'category_status' => 0,
      'category_order' => 8,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 14,
      'meta_keywords' => 'Thức ăn cho mèo,thuc an cho meo,meo thuc an,thức ăn mèo con',
      'category_name' => 'Thức ăn cho mèo',
      'slug_category_product' => 'thuc-an-cho-meo',
      'category_desc' => 'Thức ăn cho mèo',
      'category_parent' => 8,
      'category_status' => 0,
      'category_order' => 8,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  9 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 9,
      'meta_keywords' => 'Điện thoại samsung,dien thoai samsung,samsung',
      'category_name' => 'Điện thoại samsung',
      'slug_category_product' => 'dien-thoai-samsung',
      'category_desc' => 'Điện thoại samsung',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 1,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 9,
      'meta_keywords' => 'Điện thoại samsung,dien thoai samsung,samsung',
      'category_name' => 'Điện thoại samsung',
      'slug_category_product' => 'dien-thoai-samsung',
      'category_desc' => 'Điện thoại samsung',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 1,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  10 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 13,
      'meta_keywords' => 'Samsung Galaxy Note 20 Ultra',
      'category_name' => 'Samsung Galaxy Note 20 Ultra',
      'slug_category_product' => 'samsung-galaxy-note-20-ultra',
      'category_desc' => 'Samsung Galaxy Note 20 Ultra',
      'category_parent' => 9,
      'category_status' => 0,
      'category_order' => 5,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 13,
      'meta_keywords' => 'Samsung Galaxy Note 20 Ultra',
      'category_name' => 'Samsung Galaxy Note 20 Ultra',
      'slug_category_product' => 'samsung-galaxy-note-20-ultra',
      'category_desc' => 'Samsung Galaxy Note 20 Ultra',
      'category_parent' => 9,
      'category_status' => 0,
      'category_order' => 5,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  11 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 18,
      'meta_keywords' => 'Samsung Galaxy a21s',
      'category_name' => 'Samsung Galaxy a21s',
      'slug_category_product' => 'samsung-galaxy-a21s',
      'category_desc' => 'Samsung Galaxy a21s',
      'category_parent' => 9,
      'category_status' => 0,
      'category_order' => 7,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 18,
      'meta_keywords' => 'Samsung Galaxy a21s',
      'category_name' => 'Samsung Galaxy a21s',
      'slug_category_product' => 'samsung-galaxy-a21s',
      'category_desc' => 'Samsung Galaxy a21s',
      'category_parent' => 9,
      'category_status' => 0,
      'category_order' => 7,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  12 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 10,
      'meta_keywords' => 'Thiết bị số,thiet bi so,so thiet bi,bi so thiet',
      'category_name' => 'Thiết bị số',
      'slug_category_product' => 'thiet-bi-so',
      'category_desc' => 'Thiết bị số',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 1,
    ),
     'original' => 
    array (
      'category_id' => 10,
      'meta_keywords' => 'Thiết bị số,thiet bi so,so thiet bi,bi so thiet',
      'category_name' => 'Thiết bị số',
      'slug_category_product' => 'thiet-bi-so',
      'category_desc' => 'Thiết bị số',
      'category_parent' => 0,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  13 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 11,
      'meta_keywords' => 'Tai nghe,tai nghe',
      'category_name' => 'Tai nghe',
      'slug_category_product' => 'tai-nghe',
      'category_desc' => 'Tai nghe',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 2,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 11,
      'meta_keywords' => 'Tai nghe,tai nghe',
      'category_name' => 'Tai nghe',
      'slug_category_product' => 'tai-nghe',
      'category_desc' => 'Tai nghe',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 2,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  14 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 12,
      'meta_keywords' => 'Máy đo nhịp tim,may do nhip tim,tim nhip do,nhip tim',
      'category_name' => 'Máy đo nhịp tim',
      'slug_category_product' => 'may-do-nhip-tim',
      'category_desc' => 'Máy đo nhịp tim',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 12,
      'meta_keywords' => 'Máy đo nhịp tim,may do nhip tim,tim nhip do,nhip tim',
      'category_name' => 'Máy đo nhịp tim',
      'slug_category_product' => 'may-do-nhip-tim',
      'category_desc' => 'Máy đo nhịp tim',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 0,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  15 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 15,
      'meta_keywords' => 'Đồng hồ thông minh',
      'category_name' => 'Đồng hồ thông minh',
      'slug_category_product' => 'dong-ho-thong-minh',
      'category_desc' => 'Đồng hồ thông minh',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 1,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 15,
      'meta_keywords' => 'Đồng hồ thông minh',
      'category_name' => 'Đồng hồ thông minh',
      'slug_category_product' => 'dong-ho-thong-minh',
      'category_desc' => 'Đồng hồ thông minh',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 1,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  16 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 16,
      'meta_keywords' => 'Loa',
      'category_name' => 'Loa',
      'slug_category_product' => 'loa',
      'category_desc' => 'Loa',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 3,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 16,
      'meta_keywords' => 'Loa',
      'category_name' => 'Loa',
      'slug_category_product' => 'loa',
      'category_desc' => 'Loa',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 3,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
  17 => 
  App\Models\CategoryProductModel::__set_state(array(
     'connection' => 'mysql',
     'table' => 'tbl_category_product',
     'primaryKey' => 'category_id',
     'keyType' => 'int',
     'incrementing' => true,
     'with' => 
    array (
    ),
     'withCount' => 
    array (
    ),
     'preventsLazyLoading' => false,
     'perPage' => 15,
     'exists' => true,
     'wasRecentlyCreated' => false,
     'escapeWhenCastingToString' => false,
     'attributes' => 
    array (
      'category_id' => 17,
      'meta_keywords' => 'Thẻ nhớ',
      'category_name' => 'Thẻ nhớ',
      'slug_category_product' => 'the-nho',
      'category_desc' => 'Thẻ nhớ',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 4,
      'created_at' => NULL,
      'updated_at' => NULL,
      'level' => 2,
    ),
     'original' => 
    array (
      'category_id' => 17,
      'meta_keywords' => 'Thẻ nhớ',
      'category_name' => 'Thẻ nhớ',
      'slug_category_product' => 'the-nho',
      'category_desc' => 'Thẻ nhớ',
      'category_parent' => 10,
      'category_status' => 0,
      'category_order' => 4,
      'created_at' => NULL,
      'updated_at' => NULL,
    ),
     'changes' => 
    array (
    ),
     'casts' => 
    array (
    ),
     'classCastCache' => 
    array (
    ),
     'attributeCastCache' => 
    array (
    ),
     'dates' => 
    array (
    ),
     'dateFormat' => NULL,
     'appends' => 
    array (
    ),
     'dispatchesEvents' => 
    array (
    ),
     'observables' => 
    array (
    ),
     'relations' => 
    array (
    ),
     'touches' => 
    array (
    ),
     'timestamps' => false,
     'hidden' => 
    array (
    ),
     'visible' => 
    array (
    ),
     'fillable' => 
    array (
      0 => 'meta_keywords',
      1 => 'category_name',
      2 => 'slug_category_product',
      3 => 'category_desc',
      4 => 'category_status',
      5 => 'category_parent',
      6 => 'category_order',
    ),
     'guarded' => 
    array (
      0 => '*',
    ),
  )),
)                                            Thêm danh mục sản phẩm                                                                                Thuộc danh mục                                       Danh mục cha                                            Tay cầm chơi game                                                                 😒 Máy chơi game                                                                 😒😒 Quần áo cho nam                                                                 😒😒😒 Quần áo cho nữ                                                                 Sách kinh tế                                                                                                            

Last updated