Explorar el Código

edit category

azam hace 4 años
padre
commit
95b9abe7c9

+ 33 - 21
packages/product/src/Http/Controllers/CategoryController.php

@@ -5,6 +5,7 @@ namespace Packages\Product\Http\Controllers;
 use App\Http\Controllers\Controller;
 use Packages\Product\Models\Category;
 use Illuminate\Http\Request;
+use Packages\Product\Models\Product;
 
 
 class CategoryController extends Controller
@@ -14,62 +15,73 @@ class CategoryController extends Controller
         $this->middleware('auth');
     }
 
-//    **************index*********
+
     public function index()
     {
-        $categories = Category::orderBy('id','DESC')->paginate(20);
-//        dd($categories);
-
-        return view('product::categories.index',compact('categories'));
-    }
+        $categories = Category::orderBy('id', 'DESC')->paginate(20);
 
 
+        return view('product::categories.index', compact('categories'));
+    }
 
 
     public function create()
     {
-        $categories = Category::orderBy('id','DESC')->paginate(20);
+        $categories = Category::orderBy('id', 'DESC')->paginate(20);
 
-        return view('product::categories.create',compact('categories'));
+        return view('product::categories.create', compact('categories'));
     }
 
 
-
-
-
     public function store(Request $request)
     {
-        //
-    }
+
+//        dd($request->all());
+        $p = Category::create($request->all());
 
 
+        $msg = 'ذخیره محصول با موفقیت انجام شد ';
+        return redirect(route('categories-products.index'))->with('success', $msg);
+    }
 
 
     public function show(Category $category)
     {
-        //
-    }
-
 
+    }
 
 
     public function edit(Category $category)
     {
-        //
-    }
 
 
+        return view('product::categories.edit', compact('category'));
+    }
 
 
     public function update(Request $request, Category $category)
     {
-        //
-    }
 
+        try {
+            $category->update($request->all());
+
+        } catch (\Exception $exception) {
+            switch ($exception->getCode()) {
+                case 23000:
+                    $msg = 'عنوان وارد شده تکراری است';
+            }
+            return redirect(route('categories-products.index'))->with('warning', $msg);
+        }
+        $msg = 'ذخیره محصول با موفقیت انجام شد ';
+        return redirect(route('categories-products.index'))->with('success', $msg);
+    }
 
 
     public function destroy(Category $category)
     {
-        //
+        $category->delete();
+        {
+            return back();
+    }
     }
 }

+ 46 - 37
packages/product/src/Http/Controllers/ProductController.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace Packages\Product\Http\Controllers;
+
 use App\Http\Controllers\Controller;
 use Packages\Product\Models\Product;
 use Illuminate\Http\Request;
@@ -11,82 +12,90 @@ class ProductController extends Controller
     {
         $this->middleware('auth');
     }
+
 //  show  page product ************
-public function index(){
+    public function index()
+    {
 
-     $products = Product::orderBy('id','DESC')->paginate(20);
+        $products = Product::orderBy('id', 'DESC')->paginate(20);
 
-    return view('product::index',compact('products'));
+        return view('product::index', compact('products'));
+
+    }
 
-}
 // page create products *****************
-public function create(){
-    $products = Product::orderBy('id','DESC')->paginate(20);
+    public function create()
+    {
+        $products = Product::orderBy('id', 'DESC')->paginate(20);
 
-    return view('product::product.create', compact('products'));
+        return view('product::product.create', compact('products'));
+
+    }
 
-}
 // save products ******************
 
-public function store(Request $request)
+    public function store(Request $request)
     {
 
-     // dd($request->all());
-     $p = Product::create($request->all());
+        // dd($request->all());
+        $p = Product::create($request->all());
 
 
-     $msg='ذخیره محصول با موفقیت انجام شد ';
-      return redirect(route('products.index'))->with('success',$msg);
+        $msg = 'ذخیره محصول با موفقیت انجام شد ';
+        return redirect(route('products.index'))->with('success', $msg);
     }
+
     // edit page product
 
     public function edit(Product $product)
     {
 
-        $products = Product::orderBy('id','DESC')->paginate(20);
+        $products = Product::orderBy('id', 'DESC')->paginate(20);
 
         return view('product::product.edit', compact('products'));
     }
 
 // update page product
 
-    public function update(Request $request,Product $product)
+    public function update(Request $request, Product $product)
     {
-       try {
-             $product->update($request->all());
+        try {
+            $product->update($request->all());
 
-       }catch(\Exception $exception){
-           switch ($exception->getCode()){
-               case 23000:
-                    $msg='عنوان وارد شده تکراری است';
+        } catch (\Exception $exception) {
+            switch ($exception->getCode()) {
+                case 23000:
+                    $msg = 'عنوان وارد شده تکراری است';
             }
-            return redirect(route('products.index'))->with('warning',$msg);
+            return redirect(route('products.index'))->with('warning', $msg);
         }
-        $msg='ذخیره محصول با موفقیت انجام شد ';
-        return redirect(route('products.index'))->with('success',$msg);
+        $msg = 'ذخیره محصول با موفقیت انجام شد ';
+        return redirect(route('products.index'))->with('success', $msg);
     }
+
     // delete products
     public function destroy(Product $product)
     {
 
-            $product->delete();
+        $product->delete();
         {
             return back();
         }
     }
+
     // status product ****************
 
     public function updatestatus(Product $product)
     {
 
-        if ($product->status==1){
-            $product->status=0;
-        }else{
-            $product->status=1;
+        if ($product->status == 1) {
+            $product->status = 0;
+        } else {
+            $product->status = 1;
         }
         $product->save();
-        $msg="ویرایش محصول با موفقیت انجام شد";
-        return back()->with('success',$msg);
+        $msg = "ویرایش محصول با موفقیت انجام شد";
+        return back()->with('success', $msg);
 
 
     }
@@ -96,13 +105,13 @@ public function store(Request $request)
     public function updatetype(Product $product)
     {
         //
-        if ($product->type==1){
-            $product->type=0;
-        }else{
-            $product->type=1;
+        if ($product->type == 1) {
+            $product->type = 0;
+        } else {
+            $product->type = 1;
         }
         $product->save();
-        $msg="ویرایش محصول با موفقیت انجام شد";
-        return back()->with('success',$msg);
+        $msg = "ویرایش محصول با موفقیت انجام شد";
+        return back()->with('success', $msg);
     }
 }

+ 2 - 1
packages/product/src/Models/Category.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace Packages\Product\Models;
+
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
 
@@ -8,7 +9,7 @@ class Category extends Model
 {
     use SoftDeletes;
 
-    protected $guarded =[];
+    protected $guarded = [];
 
     public function user()
     {

+ 13 - 6
packages/product/src/Models/Product.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace Packages\Product\Models;
+
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
 
@@ -8,16 +9,22 @@ class Product extends Model
 {
     use SoftDeletes;
 
-    protected $guarded =[];
+    protected $guarded = [];
 
     public function user()
     {
         return $this->belongsTo(User::class);
     }
-    protected  $attributes =[
-        'status'=>0,
-        'type'=>0,
-    
-    
+
+    public function Category()
+    {
+        return $this->belongsTo(Category::class);
+    }
+
+    protected $attributes = [
+        'status' => 0,
+        'type' => 0,
+
+
     ];
 }

+ 3 - 3
packages/product/src/ProductServiceProvider.php

@@ -23,8 +23,8 @@ class ProductServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-        $this->loadRoutesFrom(__DIR__.'/routes/web.php');
-        $this->loadViewsFrom(__DIR__.'/views','product');
-        $this->loadMigrationsFrom(__DIR__.'/database/migrations');
+        $this->loadRoutesFrom(__DIR__ . '/routes/web.php');
+        $this->loadViewsFrom(__DIR__ . '/views', 'product');
+        $this->loadMigrationsFrom(__DIR__ . '/database/migrations');
     }
 }

+ 11 - 11
packages/product/src/views/categories/create.blade.php

@@ -1,4 +1,4 @@
-@component('panel.layouts.component', ['title' => 'ثبت محصول جدید'])
+@component('panel.layouts.component', ['title' => 'ثبت دسته جدید'])
 
     @slot('style')
         <style>
@@ -13,11 +13,11 @@
         </style>
     @endslot
     @slot('subject')
-        <h1><i class="fa fa-users"></i> ثبت محصول جدید </h1>
-        <p>ثبت محصول جدید در فروشگاه.</p>
+        <h1><i class="fa fa-users"></i> ثبت دسنه جدید </h1>
+
     @endslot
     @slot('breadcrumb')
-        <li class="breadcrumb-item">محصولات</li>
+        <li class="breadcrumb-item">دسته بندی محصولات</li>
     @endslot
 
     @slot('content')
@@ -29,7 +29,7 @@
                             <div class="card-header"><strong>{{ __('ثبت دسته بندی جدید') }}</strong></div>
 
                             <div class="card-body mx-lg-5 px-lg-3">
-                                <form method="POST" action="">
+                                <form method="POST" action="{{ route('categories-products.store') }}">
                                     @csrf
 
                                     <div class="form-group">
@@ -47,7 +47,7 @@
                                     </div>
 
                                     <div class="form-group">
-                                        <label for="slug">  {{ __('نام مستعار دسته  ') }}</label>
+                                        <label for="slug">  {{ __('نام مستعار دسته بندی  ') }}</label>
                                         <input id="slug" type="text"
                                                class="form-control @error('slug') is-invalid @enderror"
                                                name="slug" value="{{ old('slug') }}" required
@@ -64,8 +64,8 @@
                                         <label for="parent">  {{ __('کد  دسته بندی  ') }}</label>
                                         <input id="parent" type="text"
                                                class="form-control @error('parent') is-invalid @enderror"
-                                               name="slug" value="{{ old('parent') }}" required
-                                               autocomplete="slug" autofocus>
+                                               name="parent" value="{{ old('parent') }}" required
+                                               autocomplete="parent" autofocus>
 
                                         @error('parent')
                                         <span class="invalid-feedback" role="alert">
@@ -81,8 +81,8 @@
                                                 class="form-control @error('category_type') is-invalid @enderror"
                                                 name="category_type"
                                                 required autocomplete="category_type">
-                                            <option value="1">اصلی</option>
-                                            <option value="0">فرعی</option>
+                                            <option value="1">محصولات</option>
+                                            <option value="0">دسته بندی</option>
                                         </select>
 
                                         @error('category_type')
@@ -130,7 +130,7 @@
                                                 {{ __('ثبت دسته بندی') }}
                                             </button>
 
-                                            <a href={{ route('products.index') }} type="button" class="btn btn-warning">
+                                            <a href={{ route('categories-products.index') }} type="button" class="btn btn-warning">
                                                 انصراف</a>
 
                                         </div>

+ 123 - 216
packages/product/src/views/categories/edit.blade.php

@@ -1,249 +1,156 @@
-@extends('back.index')
-
-@section('title')
-    ویرایش دسته بندی
-@endsection
-@section('content1')
-    <!--==========================main============================-->
-
-    <div class=" main-panel col-12 col-sm-12 col-md-8 col-lg-9 col-xl-9 ">
-        <div class="container">
-            <h3 class="col-lg-12 col-md-12 col-sm-12 col-12">
-                ویرایش دسته بندی
-                @component('panel.layouts.component', ['title' => 'ویرایش دسته بندی جدید'])
-
-                    @slot('style')
-                        <style>
-                            .card-header {
-                                text-align: center !important;
-                            }
-                        </style>
-                    @endslot
-                    @slot('subject')
-                        <h1><i class="fa fa-users"></i>ویرایش دسته بندی </h1>
-                        <p></p>
-                    @endslot
-                    @slot('breadcrumb')
-                        <li class="breadcrumb-item">دسته بندی ها</li>
-                    @endslot
-
-                    @slot('content')
-                        <div class="auth-background h-auto py-5">
-                            <div class="container py-5">
-                                <div class="row align-items-center">
-                                    <div class="col-lg-8 col-md-10 mx-auto">
-                                        <div class="card">
-                                            <div class="card-header"><strong>{{ __('ویرایش دسته بندی جدید') }}</strong>
-                                            </div>
-                                            @foreach ($products as $product)
-
-
-                                                <div class="card-body mx-lg-5 px-lg-3">
-                                                    <form method="POST"
-                                                          action="{{ route('categories.update',$category->id) }}">
-                                                        @csrf
-                                                        @if ($product)
-                                                            @method('PUT')
-                                                        @endif
-
-                                                        <div class="form-group">
-                                                            <label for="title">{{ __('نام دسته بندی جدید') }}</label>
-                                                            <input id="title" type="text"
-                                                                   class="form-control @error('title') is-invalid @enderror"
-                                                                   name="title"
-                                                                   value="{{$category->title}}" required
-                                                                   autocomplete="title" autofocus>
-
-                                                            @error('title')
-                                                            <span class="invalid-feedback" role="alert">
-                                            <strong>{{ $message }}</strong>
-                                        </span>
-                                                            @enderror
+@component('panel.layouts.component', ['title' => 'ویرایش دسته جدید'])
+
+    @slot('style')
+        <style>
+            .card-header {
+                text-align: center !important;
+            }
+
+            .form-control {
+
+                background-color: hsl(315, 22%, 86%);
+            }
+        </style>
+    @endslot
+    @slot('subject')
+        <h1><i class="fa fa-users"></i> ویرایش دسته بندی </h1>
+
+    @endslot
+    @slot('breadcrumb')
+        <li class="breadcrumb-item">ویرایش دسته بندی محصولات</li>
+    @endslot
+
+    @slot('content')
+        <div class="auth-background h-auto py-5">
+            <div class="container py-5">
+                <div class="row align-items-center">
+                    <div class="col-lg-8 col-md-10 mx-auto">
+                        <div class="card">
+                            <div class="card-header"><strong>{{ __('ویرایش دسته بندی ') }}</strong></div>
 
-                                                        </div>
+                            <div class="card-body mx-lg-5 px-lg-3">
+                                <form method="POST" action="{{ route('categories-products.store') }}">
+                                    @csrf
 
-                                                        <div class="form-group">
-                                                            <label
-                                                                for="slug">  {{ __('نام مستعار دسته بندی  ') }}</label>
-                                                            <input id="slug" type="text"
-                                                                   class="form-control @error('slug') is-invalid @enderror"
-                                                                   name="slug" value="{{$category->slug}}" required
-                                                                   autocomplete="slug" autofocus>
+                                    <div class="form-group">
+                                        <label for="title">{{ __('ویرایش نام دسته بندی') }}</label>
+                                        <input id="title" type="text"
+                                               class="form-control @error('title') is-invalid @enderror" name="title"
+                                               value="{{$category->title}}" required autocomplete="title" autofocus>
 
-                                                            @error('slug')
-                                                            <span class="invalid-feedback" role="alert">
-                                            <strong>{{ $message }}</strong>
-                                        </span>
-                                                            @enderror
-
-                                                        </div>
-                                                        <div class="form-group">
-                                                            <label for="parent">  {{ __(' کد محصول  ') }}</label>
-                                                            <input id="parent" type="text"
-                                                                   class="form-control @error('parent') is-invalid @enderror"
-                                                                   name="sku" value="{{$category->parent}}" required
-                                                                   autocomplete="parent" autofocus>
-
-                                                            @error('parent')
-                                                            <span class="invalid-feedback" role="alert">
+                                        @error('title')
+                                        <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                                            @enderror
-
-                                                        </div>
-
-
-                                                        <div class="form-group">
-                                                            <label for="category_type">{{ __(' نوع محصول') }}</label>
-                                                            <select id="category_type" type="text"
-                                                                    class="form-control @error('category_type') is-invalid @enderror"
-                                                                    name="category_type"
-                                                                    required autocomplete="category_type">
-                                                                <option value="0">فرعی</option>
-                                                                <option
-                                                                    value="1" <?php if ($category->category_type == 1) echo 'selected'?> >
-                                                                    اصلی
-                                                                </option>
-                                                            </select>
-
-                                                            @error('category_type')
-                                                            <span class="invalid-feedback" role="alert">
-                                                                <strong>{{ $message }}</strong>
-                                                            </span>
-                                                            @enderror
-                                                        </div>
-
-                                                        <div class="form-group">
-                                                            <label for="status">{{ __(' وضعیت محصول') }}</label>
-                                                            <select id="status" type="text"
-                                                                    class="form-control @error('status') is-invalid @enderror"
-                                                                    name="status"
-                                                                    value="{{$product->status}}" required
-                                                                    autocomplete="status">
-                                                                <option value="0">ناموجود</option>
-                                                                <option
-                                                                    value="1" <?php if ($category->status == 1) echo 'selected'?> >
-                                                                    موجود
-                                                                </option>
-                                                            </select>
-
-
-                                                            @error('status')
-                                                            <span class="invalid-feedback" role="alert">
+                                        @enderror
+
+                                    </div>
+
+                                    <div class="form-group">
+                                        <label for="slug">  {{ __('ویرایش نام مستعار دسته بندی  ') }}</label>
+                                        <input id="slug" type="text"
+                                               class="form-control @error('slug') is-invalid @enderror"
+                                               name="slug" value="{{$category->slug}}" required
+                                               autocomplete="slug" autofocus>
+
+                                        @error('slug')
+                                        <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                                            @enderror
-                                                        </div>
-
-                                                        <div class="form-group">
-                                                            <label for="discription">{{ __(' توضیحات  محصول') }}</label>
-                                                            <textarea id="discription" type="text"
-                                                                      class="form-control @error('discription') is-invalid @enderror"
-                                                                      name="discription"
-                                                                      required
-                                                                      autocomplete="discription">{{$product->discription}}</textarea>
-
-                                                            @error('discription')
-                                                            <span class="invalid-feedback" role="alert">
+                                        @enderror
+
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="parent">  {{ __('ویرایش کد دسته بندی  ') }}</label>
+                                        <input id="parent" type="text"
+                                               class="form-control @error('parent') is-invalid @enderror"
+                                               name="parent" value="{{$category->parent}}" required
+                                               autocomplete="parent" autofocus>
+
+                                        @error('parent')
+                                        <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                                            @enderror
-                                                        </div>
-
-                                                        <div class="form-group">
-                                                            <label
-                                                                for="creator_id">{{ __(' نام ثبت کننده محصول') }}</label>
-                                                            <input id="creator_id" type="text"
-                                                                   class="form-control @error('creator_id') is-invalid @enderror"
-                                                                   name="creator_id"
-                                                                   value="{{ auth()->user()->name }}" required
-                                                                   autocomplete="creator_id" readonly>
-
-                                                            @error('creator_id')
-                                                            <span class="invalid-feedback" role="alert">
+                                        @enderror
+
+                                    </div>
+
+                                    <div class="form-group">
+                                        <label for="category_type">{{ __(' ویرایش نوع دسته بندی') }}</label>
+                                        <select id="category_type" type="text"
+                                                class="form-control @error('category_type') is-invalid @enderror"
+                                                name="category_type"
+                                                required autocomplete="category_type">
+                                            <option value="1">محصولات</option>
+                                            <option value="0">دسته بندی</option>
+                                        </select>
+
+                                        @error('category_type')
+                                        <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                                            @enderror
-                                                        </div>
-
-                                                        <div class="form-group mb-0">
-                                                            <div class="">
-                                                                <button type="submit" class="btn btn-primary">
-                                                                    {{ __('ویرایش محصول') }}
-                                                                </button>
-
-                                                                <a href={{ route('products.index') }} type="button"
-                                                                   class="btn btn-warning"> انصراف</a>
-
-                                                            </div>
-                                                        </div>
-                                                    </form>
-                                                </div>
-                                            @endforeach
-                                            <div class="card-footer">
-
-                                            </div>
-                                        </div>
+                                        @enderror
                                     </div>
-                                </div>
-                            </div>
-                        </div>
-                    @endslot
-
-                    @slot('script')
 
-                    @endslot
-
-                @endcomponent
-                <hr>
-
-                <div class="row container">
-                    <div class="col-lg-12 grid-margin stretch-card">
-                        <div class="card">
-                            <div class="card-body">
-                                @include('back.users.messages')
-                                <form action="{{route('admin.categories.update',$category->id)}}" method="post">
 
-                                    @csrf
-                                    {{--    name--}}
                                     <div class="form-group">
-                                        <label for="title">نام دسته بندی جدید</label>
-                                        <input type="text" name="name"
-                                               class="form-control @error('name') is-invalid  @enderror"
-                                               value="{{$category->name}}">
-                                        @error('name')
-                                        <div class="alert alert-danger">{{$message}}</div>
+                                        <label for="discription">{{ __('ویرایش توضیحات  دسته بندی') }}</label>
+                                        <textarea id="discription" type="text"
+                                                  class="form-control @error('discription') is-invalid @enderror"
+                                                  name="discription"
+                                                  required
+                                                  autocomplete="discription">{{$category->discription}}</textarea>
+
+                                        @error('discription')
+                                        <span class="invalid-feedback" role="alert">
+                                            <strong>{{ $message }}</strong>
+                                        </span>
                                         @enderror
                                     </div>
-                                    {{--    email--}}
+
+
                                     <div class="form-group">
-                                        <label for="title">نام مستعار جدید</label>
-                                        <input type="slug" name="slug"
-                                               class="form-control @error('slug') is-invalid  @enderror"
-                                               value="{{$category->slug}}">
-                                        @error('slug')
-                                        <div class="alert alert-danger">{{$message}}</div>
+                                        <label for="creator_id">{{ __(' نام ثبت کننده دسته بندی') }}</label>
+                                        <input id="creator_id" type="text"
+                                               class="form-control @error('creator_id') is-invalid @enderror"
+                                               name="creator_id"
+                                               value="{{ auth()->user()->name }}" required autocomplete="creator_id"
+                                               readonly>
+
+                                        @error('creator_id')
+                                        <span class="invalid-feedback" role="alert">
+                                            <strong>{{ $message }}</strong>
+                                        </span>
                                         @enderror
                                     </div>
 
+                                    <div class="form-group mb-0">
+                                        <div class="">
+                                            <button type="submit" class="btn btn-primary">
+                                                {{ __('ویرایش دسته بندی') }}
+                                            </button>
 
-                                    <div class="form-group">
-                                        <button type="submit" class="btn btn-success">ذخیره</button>
-                                        <a href="{{route('admin.categories')}}" class="btn btn-warning">انصراف</a>
+                                            <a href={{ route('categories-products.index') }} type="button" class="btn btn-warning">
+                                                انصراف</a>
+
+                                        </div>
                                     </div>
                                 </form>
                             </div>
+
+                            <div class="card-footer">
+
+                            </div>
                         </div>
                     </div>
-
                 </div>
-
+            </div>
         </div>
-    </div>
-@endsection
-
-
+    @endslot
 
+    @slot('script')
 
+    @endslot
 
+@endcomponent
 

+ 16 - 34
packages/product/src/views/categories/index.blade.php

@@ -1,20 +1,3 @@
-{{--<div class="col-md-6 form-group">--}}
-{{--    <label for="parent" class="col-md-3 col-form-label">--}}
-{{--        <i class="fa fa-star text-danger"></i>--}}
-{{--        گروه</label>--}}
-{{--    <div class="col-md-9">--}}
-{{--        <select name="parent" id="parent">--}}
-{{--            <option value="">انتخاب</option>--}}
-{{--            @foreach(\App\Category::where('parent',0)->with('sub_category')->get() as $value)--}}
-{{--                <option value="{{ $value->id }}">{{ $value->title }}</option>--}}
-{{--                @if($value->sub_category->count())--}}
-{{--                    @php $i=2; @endphp--}}
-{{--                    @include('cat',['child' => $value->sub_category ,'i' => $i])--}}
-{{--                @endif--}}
-{{--            @endforeach--}}
-{{--        </select>--}}
-{{--    </div>--}}
-{{--</div>--}}
 @component('panel.layouts.component', ['title' => 'محصولات'])
 
     @slot('style')
@@ -39,7 +22,8 @@
                                 <form class="clearfix">
                                     <div class="form-group">
                                         <label for="text-name-input">نام دسته بندی</label>
-                                        <input type="text" class="form-control" id="text-name-input" placeholder="نام دسته">
+                                        <input type="text" class="form-control" id="text-name-input"
+                                               placeholder="نام دسته">
                                     </div>
                                     <button type="submit" class="btn btn-primary float-left">جستجو</button>
                                 </form>
@@ -47,20 +31,20 @@
                         @endcomponent
 
                         <div class="mt-4">
-                            <a href="{{ route('categories-products.create') }}" type="button" class="btn btn-primary"><i class="fa fa-plus"></i> ایجاد دسته بندی</a>
+                            <a href="{{ route('categories-products.create') }}" type="button" class="btn btn-primary"><i
+                                    class="fa fa-plus"></i> ایجاد دسته بندی</a>
                         </div>
 
                         @component('components.table')
                             @slot('thead')
                                 <tr>
-                                    <th>شماره</th>
-                                    <th>نام دسته</th>
+                                    <th>شماره بندی</th>
+                                    <th>نام دسته بندی</th>
                                     <th>slug</th>
-                                    <th> کد دسته</th>
-                                    <th>توضیح دسته </th>
-
-                                    <th>توضیحات دسته</th>
-
+                                    <th>نوع دسته بندی</th>
+                                    <th> کد دسته بندی</th>
+                                    <th>توضیحات دسته بندی</th>
+                                    <th> اضافه کننده دسته بندی</th>
                                     <th> مدیریت</th>
                                 </tr>
                             @endslot
@@ -78,24 +62,22 @@
                                             {{$category->slug}}
                                         </td>
                                         <td>
-                                            {{$category->sku}}
-                                        </td>
-                                        <td>
-                                            {{$category->price}}
+                                            {{$category->category_type}}
                                         </td>
                                         <td>
-                                            {{$category->sale_price}}
+                                            {{$category->parent}}
                                         </td>
+                                        <td><?php  echo mb_substr(strip_tags($category->discription), 0, 15, 'UTF8') . '...'?></td>
+
                                         <td>
                                             {{$category->creator_id}}
                                         </td>
 
-                                        <td><?php  echo mb_substr(strip_tags($category->discription), 0, 15, 'UTF8') . '...'?></td>
                                         <td class="d-flex">
-                                            <a href="{{route('categotie.edit', $category->id)}}"
+                                            <a href="{{route('categories-products.edit', $category->id)}}"
                                                class="btn btn-sm btn-primary mr-2">ویرایش</a>
                                             <form
-                                                action="{{route('categotie.destroy', $category->id)}}"
+                                                action="{{route('categories-products.destroy', $category->id)}}"
                                                 method="POST"
                                                 onsubmit="return confirm('آیا مطمئن هستید؟');"
                                             >

+ 4 - 2
packages/product/src/views/index.blade.php

@@ -22,7 +22,8 @@
                                 <form class="clearfix">
                                     <div class="form-group">
                                         <label for="text-name-input">نام محصول</label>
-                                        <input type="text" class="form-control" id="text-name-input" placeholder="نام محصول">
+                                        <input type="text" class="form-control" id="text-name-input"
+                                               placeholder="نام محصول">
                                     </div>
                                     <button type="submit" class="btn btn-primary float-left">جستجو</button>
                                 </form>
@@ -30,7 +31,8 @@
                         @endcomponent
 
                         <div class="mt-4">
-                            <a href="{{ route('products.create') }}" type="button" class="btn btn-primary"><i class="fa fa-plus"></i> ایجاد محصول</a>
+                            <a href="{{ route('products.create') }}" type="button" class="btn btn-primary"><i
+                                    class="fa fa-plus"></i> ایجاد محصول</a>
                         </div>
 
                         @component('components.table')

+ 31 - 18
packages/product/src/views/product/create.blade.php

@@ -1,9 +1,16 @@
 @component('panel.layouts.component', ['title' => 'ثبت محصول جدید'])
 
     @slot('style')
-    .card-header {
-        text-align: center !important;
-    }
+        <style>
+            .card-header {
+                text-align: center !important;
+            }
+
+            .form-control {
+
+                background-color: hsl(315, 22%, 86%);
+            }
+        </style>
     @endslot
     @slot('subject')
         <h1><i class="fa fa-users"></i> ثبت محصول جدید </h1>
@@ -58,7 +65,7 @@
                                         <label for="price">  {{ __('قیمت محصول ') }}</label>
                                         <input id="price" type="text"
                                                class="form-control @error('price') is-invalid @enderror" name="price"
-                                               value="{{ old('price') }}" required autocomplete="price" autofocus >
+                                               value="{{ old('price') }}" required autocomplete="price" autofocus>
 
                                         @error('price')
                                         <span class="invalid-feedback" role="alert">
@@ -70,7 +77,8 @@
                                     <div class="form-group">
                                         <label for="sale_price">{{ __('قیمت فروش') }}</label>
                                         <input id="sale_price" type="sale_price"
-                                               class="form-control @error('sale_price') is-invalid @enderror" name="sale_price"
+                                               class="form-control @error('sale_price') is-invalid @enderror"
+                                               name="sale_price"
                                                value="{{ old('sale_price') }}" required autocomplete="sale_price">
 
                                         @error('sale_price')
@@ -83,9 +91,9 @@
                                     <div class="form-group">
                                         <label for="type">{{ __(' نوع محصول') }}</label>
                                         <select id="type" type="text"
-                                               class="form-control @error('type') is-invalid @enderror" name="type"
+                                                class="form-control @error('type') is-invalid @enderror" name="type"
                                                 required autocomplete="type">
-                                               <option value="1">اصلی</option>
+                                            <option value="1">اصلی</option>
                                             <option value="0">فرعی</option>
                                         </select>
 
@@ -99,10 +107,10 @@
                                     <div class="form-group">
                                         <label for="status">{{ __(' وضعیت محصول') }}</label>
                                         <select id="status" type="text"
-                                               class="form-control @error('status') is-invalid @enderror" name="status"
-                                               value="{{ old('status') }}" required autocomplete="status">
-                                               <option value="1">موجود</option>
-                                               <option value="0">ناموجود</option>
+                                                class="form-control @error('status') is-invalid @enderror" name="status"
+                                                value="{{ old('status') }}" required autocomplete="status">
+                                            <option value="1">موجود</option>
+                                            <option value="0">ناموجود</option>
                                         </select>
 
 
@@ -116,8 +124,10 @@
                                     <div class="form-group">
                                         <label for="discription">{{ __(' توضیحات  محصول') }}</label>
                                         <textarea id="discription" type="text"
-                                               class="form-control @error('discription') is-invalid @enderror" name="discription"
-                                                required autocomplete="discription">{{ old('discription') }}</textarea>
+                                                  class="form-control @error('discription') is-invalid @enderror"
+                                                  name="discription"
+                                                  required
+                                                  autocomplete="discription">{{ old('discription') }}</textarea>
 
                                         @error('discription')
                                         <span class="invalid-feedback" role="alert">
@@ -128,8 +138,8 @@
                                     <div class="form-group">
                                         <label for="sku">{{ __(' کد  محصول') }}</label>
                                         <textarea id="sku" type="text"
-                                               class="form-control @error('sku') is-invalid @enderror" name="sku"
-                                                required autocomplete="sku">{{ old('sku') }}</textarea>
+                                                  class="form-control @error('sku') is-invalid @enderror" name="sku"
+                                                  required autocomplete="sku">{{ old('sku') }}</textarea>
 
                                         @error('sku')
                                         <span class="invalid-feedback" role="alert">
@@ -141,8 +151,10 @@
                                     <div class="form-group">
                                         <label for="creator_id">{{ __(' نام ثبت کننده محصول') }}</label>
                                         <input id="creator_id" type="text"
-                                               class="form-control @error('creator_id') is-invalid @enderror" name="creator_id"
-                                               value="{{ auth()->user()->name }}" required autocomplete="creator_id" readonly>
+                                               class="form-control @error('creator_id') is-invalid @enderror"
+                                               name="creator_id"
+                                               value="{{ auth()->user()->name }}" required autocomplete="creator_id"
+                                               readonly>
 
                                         @error('creator_id')
                                         <span class="invalid-feedback" role="alert">
@@ -157,7 +169,8 @@
                                                 {{ __('ثبت محصول') }}
                                             </button>
 
-                                            <a href={{ route('products.index') }} type="button" class="btn btn-warning"> انصراف</a>
+                                            <a href={{ route('products.index') }} type="button" class="btn btn-warning">
+                                                انصراف</a>
 
                                         </div>
                                     </div>

+ 133 - 113
packages/product/src/views/product/edit.blade.php

@@ -1,9 +1,16 @@
 @component('panel.layouts.component', ['title' => 'ویرایش محصول جدید'])
 
     @slot('style')
-    .card-header {
-        text-align: center !important;
-    }
+        <style>
+            .card-header {
+                text-align: center !important;
+            }
+
+            .form-control {
+
+                background-color: hsl(315, 22%, 86%);
+            }
+        </style>
     @endslot
     @slot('subject')
         <h1><i class="fa fa-users"></i>ویرایش محصولات </h1>
@@ -23,153 +30,166 @@
                             @foreach ($products as $product)
 
 
-                            <div class="card-body mx-lg-5 px-lg-3">
-                                <form method="POST" action="{{ route('products.update',$product->id) }}">
-                                    @csrf
-                                    @if ($product)
-                                @method('PUT')
-                                 @endif
+                                <div class="card-body mx-lg-5 px-lg-3">
+                                    <form method="POST" action="{{ route('products.update',$product->id) }}">
+                                        @csrf
+                                        @if ($product)
+                                            @method('PUT')
+                                        @endif
 
-                                    <div class="form-group">
-                                        <label for="title">{{ __('نام محصول جدید') }}</label>
-                                        <input id="title" type="text"
-                                               class="form-control @error('title') is-invalid @enderror" name="title"
-                                               value="{{$product->title}}" required autocomplete="title" autofocus>
+                                        <div class="form-group">
+                                            <label for="title">{{ __('نام محصول جدید') }}</label>
+                                            <input id="title" type="text"
+                                                   class="form-control @error('title') is-invalid @enderror"
+                                                   name="title"
+                                                   value="{{$product->title}}" required autocomplete="title" autofocus>
 
-                                        @error('title')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('title')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
+                                            @enderror
 
-                                    </div>
+                                        </div>
 
-                                    <div class="form-group">
-                                        <label for="slug">  {{ __('نام مستعار محصول  ') }}</label>
-                                        <input id="slug" type="text"
-                                               class="form-control @error('slug') is-invalid @enderror"
-                                               name="slug" value="{{$product->slug}}" required
-                                               autocomplete="slug" autofocus>
+                                        <div class="form-group">
+                                            <label for="slug">  {{ __('نام مستعار محصول  ') }}</label>
+                                            <input id="slug" type="text"
+                                                   class="form-control @error('slug') is-invalid @enderror"
+                                                   name="slug" value="{{$product->slug}}" required
+                                                   autocomplete="slug" autofocus>
 
-                                        @error('slug')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('slug')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-
-                                    </div>
-                                    <div class="form-group">
-                                        <label for="sku">  {{ __(' کد محصول  ') }}</label>
-                                        <input id="sku" type="text"
-                                               class="form-control @error('sku') is-invalid @enderror"
-                                               name="sku" value="{{$product->sku}}" required
-                                               autocomplete="sku" autofocus>
-
-                                        @error('sku')
-                                        <span class="invalid-feedback" role="alert">
+                                            @enderror
+
+                                        </div>
+                                        <div class="form-group">
+                                            <label for="sku">  {{ __(' کد محصول  ') }}</label>
+                                            <input id="sku" type="text"
+                                                   class="form-control @error('sku') is-invalid @enderror"
+                                                   name="sku" value="{{$product->sku}}" required
+                                                   autocomplete="sku" autofocus>
+
+                                            @error('sku')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
+                                            @enderror
 
-                                    </div>
+                                        </div>
 
-                                    <div class="form-group">
-                                        <label for="price">  {{ __('قیمت محصول ') }}</label>
-                                        <input id="price" type="text"
-                                               class="form-control @error('price') is-invalid @enderror" name="price"
-                                               value="{{$product->price}}" required autocomplete="price" autofocus>
+                                        <div class="form-group">
+                                            <label for="price">  {{ __('قیمت محصول ') }}</label>
+                                            <input id="price" type="text"
+                                                   class="form-control @error('price') is-invalid @enderror"
+                                                   name="price"
+                                                   value="{{$product->price}}" required autocomplete="price" autofocus>
 
-                                        @error('price')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('price')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
+                                            @enderror
+                                        </div>
 
-                                    <div class="form-group">
-                                        <label for="sale_price">{{ __('قیمت فروش') }}</label>
-                                        <input id="sale_price" type="sale_price"
-                                               class="form-control @error('sale_price') is-invalid @enderror" name="sale_price"
-                                               value="{{$product->sale_price}}" required autocomplete="sale_price">
+                                        <div class="form-group">
+                                            <label for="sale_price">{{ __('قیمت فروش') }}</label>
+                                            <input id="sale_price" type="sale_price"
+                                                   class="form-control @error('sale_price') is-invalid @enderror"
+                                                   name="sale_price"
+                                                   value="{{$product->sale_price}}" required autocomplete="sale_price">
 
-                                        @error('sale_price')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('sale_price')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
-
-                                    <div class="form-group">
-                                        <label for="type">{{ __(' نوع محصول') }}</label>
-                                        <select id="type" type="text"
-                                               class="form-control @error('type') is-invalid @enderror" name="type"
-                                                required autocomplete="type">
-                                               <option value="0">فرعی</option>
-                                            <option value="1" <?php if ($product->type==1) echo 'selected'?> >اصلی</option>
-                                        </select>
-
-                                        @error('sku')
-                                        <span class="invalid-feedback" role="alert">
+                                            @enderror
+                                        </div>
+
+                                        <div class="form-group">
+                                            <label for="type">{{ __(' نوع محصول') }}</label>
+                                            <select id="type" type="text"
+                                                    class="form-control @error('type') is-invalid @enderror" name="type"
+                                                    required autocomplete="type">
+                                                <option value="0">فرعی</option>
+                                                <option value="1" <?php if ($product->type == 1) echo 'selected'?> >
+                                                    اصلی
+                                                </option>
+                                            </select>
+
+                                            @error('sku')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
-
-                                    <div class="form-group">
-                                        <label for="status">{{ __(' وضعیت محصول') }}</label>
-                                        <select id="status" type="text"
-                                               class="form-control @error('status') is-invalid @enderror" name="status"
-                                               value="{{$product->status}}" required autocomplete="status">
-                                               <option value="0">ناموجود</option>
-                                               <option value="1" <?php if ($product->status==1) echo 'selected'?> >موجود</option>
-                                        </select>
-
+                                            @enderror
+                                        </div>
 
-                                        @error('status')
-                                        <span class="invalid-feedback" role="alert">
+                                        <div class="form-group">
+                                            <label for="status">{{ __(' وضعیت محصول') }}</label>
+                                            <select id="status" type="text"
+                                                    class="form-control @error('status') is-invalid @enderror"
+                                                    name="status"
+                                                    value="{{$product->status}}" required autocomplete="status">
+                                                <option value="0">ناموجود</option>
+                                                <option value="1" <?php if ($product->status == 1) echo 'selected'?> >
+                                                    موجود
+                                                </option>
+                                            </select>
+
+
+                                            @error('status')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
+                                            @enderror
+                                        </div>
 
-                                    <div class="form-group">
-                                        <label for="discription">{{ __(' توضیحات  محصول') }}</label>
-                                        <textarea id="discription" type="text"
-                                               class="form-control @error('discription') is-invalid @enderror" name="discription"
-                                                required autocomplete="discription" >{{$product->discription}}</textarea>
+                                        <div class="form-group">
+                                            <label for="discription">{{ __(' توضیحات  محصول') }}</label>
+                                            <textarea id="discription" type="text"
+                                                      class="form-control @error('discription') is-invalid @enderror"
+                                                      name="discription"
+                                                      required
+                                                      autocomplete="discription">{{$product->discription}}</textarea>
 
-                                        @error('discription')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('discription')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
+                                            @enderror
+                                        </div>
 
-                                    <div class="form-group">
-                                        <label for="creator_id">{{ __(' نام ثبت کننده محصول') }}</label>
-                                        <input id="creator_id" type="text"
-                                               class="form-control @error('creator_id') is-invalid @enderror" name="creator_id"
-                                               value="{{ auth()->user()->name }}" required autocomplete="creator_id" readonly>
+                                        <div class="form-group">
+                                            <label for="creator_id">{{ __(' نام ثبت کننده محصول') }}</label>
+                                            <input id="creator_id" type="text"
+                                                   class="form-control @error('creator_id') is-invalid @enderror"
+                                                   name="creator_id"
+                                                   value="{{ auth()->user()->name }}" required autocomplete="creator_id"
+                                                   readonly>
 
-                                        @error('creator_id')
-                                        <span class="invalid-feedback" role="alert">
+                                            @error('creator_id')
+                                            <span class="invalid-feedback" role="alert">
                                             <strong>{{ $message }}</strong>
                                         </span>
-                                        @enderror
-                                    </div>
+                                            @enderror
+                                        </div>
 
-                                    <div class="form-group mb-0">
-                                        <div class="">
-                                            <button type="submit" class="btn btn-primary">
-                                                {{ __('ویرایش محصول') }}
-                                            </button>
+                                        <div class="form-group mb-0">
+                                            <div class="">
+                                                <button type="submit" class="btn btn-primary">
+                                                    {{ __('ویرایش محصول') }}
+                                                </button>
 
-                                            <a href={{ route('products.index') }} type="button" class="btn btn-warning"> انصراف</a>
+                                                <a href={{ route('products.index') }} type="button"
+                                                   class="btn btn-warning"> انصراف</a>
 
+                                            </div>
                                         </div>
-                                    </div>
-                                </form>
-                            </div>
+                                    </form>
+                                </div>
                             @endforeach
                             <div class="card-footer">