Jelajahi Sumber

test add value attribute input

Azam Rezayi 4 tahun lalu
induk
melakukan
cc966b1153

+ 85 - 0
app/Http/Controllers/AttributablesController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\attributables;
+use Illuminate\Http\Request;
+
+class AttributablesController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\attributables  $attributables
+     * @return \Illuminate\Http\Response
+     */
+    public function show(attributables $attributables)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\attributables  $attributables
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(attributables $attributables)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\attributables  $attributables
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, attributables $attributables)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\attributables  $attributables
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(attributables $attributables)
+    {
+        //
+    }
+}

+ 272 - 0
electe to array

@@ -0,0 +1,272 @@
+commit 63281548a4041d608e886d24a120d23f15d36c1c (HEAD -> azam_prouduct)
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Aug 19 10:16:55 2020 +0430
+
+     add value to array
+
+commit aee98cacd49d6816af8913da22ea7f4bd64181a8 (origin/azam_prouduct)
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 18 17:02:39 2020 +0430
+
+    Add selecte to array to
+
+commit 0d7c644124341f122da90750964f72c891af681a
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 18 15:11:11 2020 +0430
+
+    Add selecte to array
+
+commit ba72c14cce6f464571c971f9397d337a863612e6
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Aug 17 17:25:02 2020 +0430
+
+    End insert value attribute
+
+commit 7d4f7c979faf9b24d2cfe61dbd99e7091944b06e
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Aug 16 17:18:50 2020 +0430
+
+    Check out the feature appearance form
+
+commit 519a235e507565647cb5aa78fa92823ca33c44d6
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Aug 15 17:31:03 2020 +0430
+
+    End input attribute
+
+commit c82ecd8f5dab3d4a44354fa30a431b1f136ee532
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 11 17:08:17 2020 +0430
+
+     Record Attribute
+
+commit b60dff78be74417a95582e3b4d5b4446713aed84
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 11 15:13:50 2020 +0430
+
+     Record simple to variable
+
+commit ceb4b083e70abec0c2e84f17a311df3abd43f5cf
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 11 10:15:59 2020 +0430
+
+     Record simple
+
+commit 7d695ad22c1243e564545bdaa18352e6ea710633
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Aug 10 17:49:49 2020 +0430
+
+    create page variable and incloud Attribute
+
+commit 46d9c462b4b017d4a7e536ed4d36edc94c59b2b2
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Aug 10 10:41:19 2020 +0430
+
+    Edit ages pruduct SimplePages
+
+commit 19bf5465e57ed25b7681f113c707deb409ce6588
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Aug 9 17:11:10 2020 +0430
+
+    End create feature
+
+commit 14ce15e6bd4de998ea2ce0f7a269c46187d0b428
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Aug 5 16:59:54 2020 +0430
+
+     End ulad file image the input gallery and feature
+
+commit b7e3027d7b7e404b495eb0921acfdcdfd799aae9
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 4 16:59:38 2020 +0430
+
+     Edit uploadable_id image by ajax
+
+commit def37f3069bdd744fd06482f5ca9f4622ec94cf2
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Aug 4 14:43:52 2020 +0430
+
+     END test upload image by ajax
+
+commit d77babdf32daf1496ad69600723c2e97b2f45d1e
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Aug 3 13:07:45 2020 +0430
+
+    Edit filde feacher images in the pages product edit
+
+commit 8e9ba7548a3bb0752e710ef7d862519c25dd8886
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Aug 2 17:31:54 2020 +0430
+
+     Edit file attachmant
+
+commit 4205611a89e71a64d2c7d8007751e2da25c9533d
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Aug 2 14:57:22 2020 +0430
+
+     End filde draft
+
+commit 3fdf4bc1595cbfc733a9c64a0a6b72ad8f04a836
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Aug 1 17:20:17 2020 +0430
+
+    Save migration draft and attachment
+
+commit e1761525b2ab30b0ff30abffc399e265d7eed5f8
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Aug 1 12:48:17 2020 +0430
+
+    Create migration draft and attachment
+
+commit e2d0bdd5082429b86a4148452cb1252d71e49988
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 29 17:39:08 2020 +0430
+
+    Edited form send data ajax
+
+commit acadbe2c941eb73534c7b553b67213c2d0ded327
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 29 11:32:22 2020 +0430
+
+     edit pkages ckeditor5
+
+commit c760530ad13b63e170b091dc6a1959f1a861faad
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 29 09:53:46 2020 +0430
+
+     install tinymce (editor) for panel
+
+commit 500b7029328892a449ce6bfbec9e9122a6b19ea3
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 29 09:28:52 2020 +0430
+
+     uninstall pkages ckeditor5
+
+commit fea37cc0ad6fe7f53fa6cf2fb68ae7a63d5b35dc
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 28 17:36:52 2020 +0430
+
+     end Release status and parent and
+
+commit 79ea1adceb47bffb7115f6e4476e1dd1f926d1e5
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 22 17:32:48 2020 +0430
+
+     use sluggable
+
+commit 3173f67c7ff47a48efff3aa4e19f81fca4c888f7
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 22 10:15:56 2020 +0430
+
+     edite pege edit upload images
+
+commit 6fb5f656d73f71d78d50d6f40f92fad0729e6418
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 21 17:28:34 2020 +0430
+
+     Continuation page edit product
+
+commit 7d78698daed463870e536beb5be45eb3c5a53028
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Jul 19 18:01:44 2020 +0430
+
+    end feilde gallery images
+
+commit 03b0af299488620b5a4ca507af243f92383271d1
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Jul 18 17:24:57 2020 +0430
+
+     teset inpute gallery images
+
+commit e6d84d297664687e7e26ab2c9b5aa946210ebb4d
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Wed Jul 15 16:53:46 2020 +0430
+
+    update input feature image
+
+commit fa78868d9b59cdaccf97b148e451a94256efeb6a
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 14 17:35:32 2020 +0430
+
+     end button clos in the featue images
+
+commit 5c9764a68ba3beaea2839a8dde4d648d37c186bf
+Author: azam <azam.rezayi2261@gmail.com>
+Date:   Mon Jul 13 10:56:33 2020 -0800
+
+    input gallery
+
+commit c97d0dd5130beee3db0edf97325c310bea9023d1
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Jul 13 17:06:01 2020 +0430
+
+     Completion input feature images
+
+commit 928167380b8210f57bde04e5b6d0ae4a09c9a2ed
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Jul 12 17:16:24 2020 +0430
+
+     edit input featued
+
+commit b41267761a2f1a7b822e85223bd2c0b4010a64a7
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Jul 11 17:14:15 2020 +0430
+
+     edit button delete file product and edit page create and edit
+
+commit 9ba6dcc6bcf5149670295ce353017e328830e73c
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 7 17:11:33 2020 +0430
+
+     upload  in the delet  image
+
+commit ee276b3bce230b2fe5295bc57f3bc7292c45a5b2
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 7 17:11:23 2020 +0430
+
+     upload  in the delet  image
+
+commit 7439b19bbac0929e07ff8a781ab3534f1736ab56
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Tue Jul 7 13:48:11 2020 +0430
+
+     end create upload image in the product
+
+commit be8ca06b2a0a7f9f6590792da7bc59c7810c02ae
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Jul 6 17:23:18 2020 +0430
+
+    Murphy's review between uploading with products
+
+commit 00f8704207b270f225dc3c3f19d1fe9c390409c5
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Mon Jul 6 01:22:32 2020 -0700
+
+    end morhp upload
+
+commit 41737dc9f98c22da97d7d5b0a1069d2ceac31178
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Jul 5 06:05:04 2020 -0700
+
+    end morph upload
+
+commit 502d5acc38ba75d34aca413c1bcd0f665b4ba4a8
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sun Jul 5 00:51:49 2020 -0700
+
+    make tabale upload
+
+commit f4444e09653ca4256975f716c1864d32a00ddc19
+Author: Azam Rezayi <azam.rezayi2261@gmail.com>
+Date:   Sat Jul 4 21:31:21 2020 -0700
+
+    create tabale photo
+
+commit 1ef5ab283739f53882d0d58bafa1de4f9d5e6306
+Author: azam <azam.rezayi2261@gmail.com>
+Date:   Sat Jul 4 05:07:39 2020 -0800
+
+     Correction table photo in the morhp
+
+commit 85d516a3b33662d663bfd0251087946b39c40563
+Author: azam <azam.rezayi2261@gmail.co

+ 21 - 13
packages/product/src/Http/Controllers/ProductController.php

@@ -11,6 +11,9 @@ use Illuminate\Support\Facades\Facade;
 use Illuminate\Support\Facades\File;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Str;
+use Packages\Product\Http\Requests\AttributableRequest;
+use Packages\Product\Http\Requests\AttributeRequest;
+use Packages\Product\Models\attributables;
 use Packages\Product\Models\Attribute;
 use Packages\Product\Models\Draft;
 use Packages\Product\Http\Requests\ProductRequest;
@@ -19,7 +22,6 @@ use Packages\Product\Models\Product;
 use Illuminate\Http\Request;
 use App\Models\Category;
 use App\Models\Upload;
-use Packages\Product\Models\Temp;
 use phpDocumentor\Reflection\Types\Compound;
 
 class ProductController extends Controller
@@ -95,12 +97,12 @@ class ProductController extends Controller
     {
         $attributes = Attribute::orderBy('id')->where('use_in_veriation', 1)->get();
 
-        $attributables = \DB::table('attributables')->where('val_attribute', true)->get();
+//        $attributables = \DB::table('attributables')->where('val_attribute', true)->get();
 //        dd($attributables->val_attribute);
         $product = $this->productChecker($id);
         if ($product != false){
             $msg = 'ذخیره محصول با موفقیت انجام شد ';
-            return view('product::product.variableProduct', compact('product', 'attributes', 'attributables'))->with('success', $msg);
+            return view('product::product.variableProduct', compact('product', 'attributes'))->with('success', $msg);
         }else{
             return abort(419);
         }
@@ -197,20 +199,26 @@ class ProductController extends Controller
         session()->flash('image_deleted', $msg);
         return redirect()->back();
     }
-//    ****************************uploadGallery********************
-    public function uploadValAttribute(Request $request)
+//    ****************************                                                                                         ********************
+    public function addValAttribute(AttributableRequest $request )
     {
-        $attributes=Attribute::orderBy('title')->get();
         $productID = $request->productID;
-//       dd( [$request->val_attribute]);
         $product = Product::where('id', $productID)->first();
-        $attributes = [];
-        foreach ( $request->val_attribute as $attr_id => $values ){
-            $attributes[ $attr_id ] = ['val_attribute' => $values];
+
+        foreach ( $request->val_attribute as $attr_id => $values){
+            foreach ( $values as $value ){
+                echo $attr_id . $value;
+                die();
+            }
+            $data = [
+                'val_attribute' => [$request->val_attribute],
+                'attribute_id'=>  $attr_id,
+                'attributable_id' => $request->productID,
+                'attributable_type' => 'Packages\Product\Models\Product',
+            ];
+           dd($data);
+            $attributables =Attributables::create($data);
 
         }
-//       dd($attributes);
-       $product->attributes()->sync($attributes);
-//dd($attributesd);
     }
 }

+ 35 - 0
packages/product/src/Http/Requests/AttributableRequest.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Packages\Product\Http\Requests;
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Validation\Rule;
+
+class AttributableRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+//     dd(request()->all());
+        return [
+            'productID' => ['required'],
+            'val_attribute' => ['required'],
+
+        ];
+
+    }
+
+}

+ 13 - 0
packages/product/src/Models/Attributables.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace Packages\Product\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class AttributeJoinProduct extends Model
+{
+    use SoftDeletes;
+    protected $table = 'attributables';
+    protected $guarded = [];
+}

+ 1 - 1
packages/product/src/Models/Attribute.php

@@ -11,7 +11,7 @@ class Attribute extends Model
     protected $fillable=['title', 'key', 'use_in_veriation'];
     public function products()
     {
-        return $this->morphedByMany(Product::class, 'attributable');
+        return $this->morphedByMany(Product::class, 'attributable')->withPivot(['val_attribute']);
     }
     public function getUseInVeriationAttribute($value)
     {

+ 1 - 0
packages/product/src/Models/Product.php

@@ -25,6 +25,7 @@ class Product extends Model
     public function attributes()
     {
         return $this->morphToMany(Attribute::class, 'attributable');
+
     }
     public function uploads()
     {

+ 3 - 1
packages/product/src/js/product.js

@@ -23,7 +23,8 @@ $(document).on('click', '.attribute_creator', function () {
         new_select.find('select').removeClass();
         new_select.find('select').addClass('newSelectItem');
         $('div.added_attribute:last').after( new_select.html() );
-        $('div.added_attribute:last').show().find('select').attr('name', 'val_attribute[' + attr_id + ']'+'[]');
+        $('div.added_attribute:last').show().find('select').attr('name', 'val_attribute[' + attr_id + '][]');
+
         $('#saveItemAttribute').show();
         $(".added_attribute select").select2({
             tags: true
@@ -40,6 +41,7 @@ $(document).on('click', '.attribute_creator', function () {
             let attribute_values = $(this).val();
             for( let i=0; i<attribute_values.length; i++ ){
                 data.append( $(this).attr('name'), attribute_values[i]);
+
             }
         });
         data.append('productID',$('#productID').val());

+ 3 - 4
packages/product/src/routes/web.php

@@ -10,10 +10,9 @@ Route::group([
 
     Route::get('product/product-variable/{id}', 'ProductController@productStepVariable')->name('productStepVariable');
 
-
-
-    Route::post('attributes_uploads/val_attribute', 'ProductController@uploadValAttribute')->name('val_attribute');
-
+//    add variable product
+    Route::post('attributes_uploads/val_attribute', 'ProductController@addValAttribute')->name('val_attribute');
+    Route::get('product/product-variabled', 'ProductController@addValAttribute')->name('addValAttribute');
 //upload*****************************
     Route::get('uploads/{upload}', 'ProductController@destroyFile')->name('uploads.destroyFile');
     Route::post('product_uploads/FeaturedImage', 'ProductController@uploadFeature')->name('FeaturedImage');

+ 13 - 13
packages/product/src/views/product/variableProduct.blade.php

@@ -34,20 +34,20 @@
                                     <div><label for="" class="label attribute">ویژگی ها</label></div>
                                     <div class="form-row attribute_style">
 
-                                        @foreach ($attributables as $item)
+{{--                                        @foreach ($attributables as $item)--}}
 {{--                                            {{dd($attributables)}}--}}
-                                            <div class="form-group col-lg-3">
-                                                <label for="slug">{{$item->attribute_id}}</label>
-                                                <select id="slug" type="text" class="form-control @error('slug') is-invalid @enderror" name="slug"  value="{{$item->val_attribute}}" autocomplete="slug" autofocus>
-                                                     <option value="{{$item->val_attribute}}"></option>
-                                                </select>
-                                                @error('slug')
-                                                <span class="invalid-feedback" role="alert">
-                                                        <strong>{{ $message }}</strong>
-                                                </span>
-                                                @enderror
-                                            </div>
-                                        @endforeach
+{{--                                            <div class="form-group col-lg-3">--}}
+{{--                                                <label for="slug">{{$item->attribute_id}}</label>--}}
+{{--                                                <select id="slug" type="text" class="form-control @error('slug') is-invalid @enderror" name="slug"  value="{{$item->val_attribute}}" autocomplete="slug" autofocus>--}}
+{{--                                                     <option value="{{$item->val_attribute}}"></option>--}}
+{{--                                                </select>--}}
+{{--                                                @error('slug')--}}
+{{--                                                <span class="invalid-feedback" role="alert">--}}
+{{--                                                        <strong>{{ $message }}</strong>--}}
+{{--                                                </span>--}}
+{{--                                                @enderror--}}
+{{--                                            </div>--}}
+{{--                                        @endforeach--}}
                                     </div>
                                     <div class="attribute_style">
                                         @include('product::product.include.simpleProduct')