@@ -7,21 +7,21 @@ |
||
| 7 | 7 | use Mongi\Mongicommerce\Http\Controllers\admin\DashboardController; |
| 8 | 8 | |
| 9 | 9 | //BackEnd Pages |
| 10 | -Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard'); |
|
| 11 | -Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new'); |
|
| 12 | -Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details'); |
|
| 10 | +Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard'); |
|
| 11 | +Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new'); |
|
| 12 | +Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details'); |
|
| 13 | 13 | //products |
| 14 | -Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new'); |
|
| 14 | +Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new'); |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | //Post |
| 21 | -Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 22 | -Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories'); |
|
| 23 | -Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 21 | +Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 22 | +Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories'); |
|
| 23 | +Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 24 | 24 | |
| 25 | 25 | //details |
| 26 | -Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail'); |
|
| 27 | -Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details'); |
|
| 26 | +Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail'); |
|
| 27 | +Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details'); |
|
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class AdminNewProductController extends Controller |
| 10 | 10 | { |
| 11 | - public function page(){ |
|
| 11 | + public function page() { |
|
| 12 | 12 | return view('mongicommerce::admin.pages.products.new_product'); |
| 13 | 13 | } |
| 14 | 14 | } |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class AdminDetailController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | $types_details = config('mongicommerce.details'); |
| 15 | - return view('mongicommerce::admin.pages.details.create_details',['types' =>$types_details ]); |
|
| 15 | + return view('mongicommerce::admin.pages.details.create_details', ['types' =>$types_details]); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function setNewDetail(Request $r){ |
|
| 18 | + public function setNewDetail(Request $r) { |
|
| 19 | 19 | |
| 20 | 20 | $r->validate([ |
| 21 | 21 | 'name' => 'required', |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | $detail->name = $name; |
| 35 | 35 | $detail->save(); |
| 36 | 36 | |
| 37 | - if($type === 'select' || $type === 'checkbox' || $type === 'radio'){ |
|
| 38 | - foreach ($values as $value){ |
|
| 37 | + if ($type === 'select' || $type === 'checkbox' || $type === 'radio') { |
|
| 38 | + foreach ($values as $value) { |
|
| 39 | 39 | $datails_value = new DetailValue(); |
| 40 | 40 | $datails_value->detail_id = $detail->id; |
| 41 | 41 | $datails_value->value = $value; |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | return response()->json(true); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function getDetails(Request $r){ |
|
| 49 | + public function getDetails(Request $r) { |
|
| 50 | 50 | $category_id = $r->get('category_id'); |
| 51 | - $details = Detail::where('category_id',$category_id)->get(); |
|
| 51 | + $details = Detail::where('category_id', $category_id)->get(); |
|
| 52 | 52 | $d = []; |
| 53 | - foreach ($details as $detail){ |
|
| 53 | + foreach ($details as $detail) { |
|
| 54 | 54 | $d[] = [ |
| 55 | 55 | 'name' => $detail->name, |
| 56 | 56 | 'type' => $detail->type, |
| 57 | 57 | 'values' => $detail->values, |
| 58 | - 'html' => $this->generateDetailHtml($detail,$detail->values) |
|
| 58 | + 'html' => $this->generateDetailHtml($detail, $detail->values) |
|
| 59 | 59 | ]; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,50 +63,50 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function generateDetailHtml($detail,$values){ |
|
| 66 | + public function generateDetailHtml($detail, $values) { |
|
| 67 | 67 | $type = $detail->type; |
| 68 | 68 | |
| 69 | - if($type === 'select'){ |
|
| 69 | + if ($type === 'select') { |
|
| 70 | 70 | $html = ''; |
| 71 | - $html .= '<select data-detail_id="'.$detail->id .'" class="form-control mongifield">'; |
|
| 71 | + $html .= '<select data-detail_id="'.$detail->id.'" class="form-control mongifield">'; |
|
| 72 | 72 | $html .= '<option value="">Seleziona</option>'; |
| 73 | - foreach($values as $value){ |
|
| 73 | + foreach ($values as $value) { |
|
| 74 | 74 | $html .= '<option value="'.$value->id.'">'.$value->value.'</option>'; |
| 75 | 75 | } |
| 76 | 76 | $html .= '</select>'; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if($type === 'checkbox'){ |
|
| 79 | + if ($type === 'checkbox') { |
|
| 80 | 80 | $html = ''; |
| 81 | 81 | |
| 82 | - foreach($values as $value){ |
|
| 82 | + foreach ($values as $value) { |
|
| 83 | 83 | $html .= '<div class="custom-control custom-checkbox mongifield">'; |
| 84 | - $html .= '<input data-detail_id="'.$detail->id .'" type="checkbox" class="custom-control-input mongifield" id="defaultUnchecked_'.$value->id.'">'; |
|
| 84 | + $html .= '<input data-detail_id="'.$detail->id.'" type="checkbox" class="custom-control-input mongifield" id="defaultUnchecked_'.$value->id.'">'; |
|
| 85 | 85 | $html .= '<label class="custom-control-label" for="defaultUnchecked_'.$value->id.'">'.$value->value.'</label>'; |
| 86 | 86 | $html .= '</div>'; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if($type === 'radio'){ |
|
| 90 | + if ($type === 'radio') { |
|
| 91 | 91 | $html = ''; |
| 92 | - foreach($values as $value){ |
|
| 92 | + foreach ($values as $value) { |
|
| 93 | 93 | $html .= '<div class="custom-control custom-radio mongifield">'; |
| 94 | - $html .= '<input name="radio_'.$value->detail_id.'" data-detail_id="'.$detail->id .'" type="radio" class="custom-control-input mongifield" id="defaultradio_'.$value->id.'">'; |
|
| 94 | + $html .= '<input name="radio_'.$value->detail_id.'" data-detail_id="'.$detail->id.'" type="radio" class="custom-control-input mongifield" id="defaultradio_'.$value->id.'">'; |
|
| 95 | 95 | $html .= '<label class="custom-control-label" for="defaultradio_'.$value->id.'">'.$value->value.'</label>'; |
| 96 | 96 | $html .= '</div>'; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if($type === 'text'){ |
|
| 101 | - $html = '<input data-detail_id="'.$detail->id .'" type="text" class="form-control mongifield" id="text_' . $detail->id . '">'; |
|
| 100 | + if ($type === 'text') { |
|
| 101 | + $html = '<input data-detail_id="'.$detail->id.'" type="text" class="form-control mongifield" id="text_'.$detail->id.'">'; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if($type === 'number'){ |
|
| 105 | - $html = '<input data-detail_id="'.$detail->id .'" type="number" class="form-control mongifield" id="number_' . $detail->id . '">'; |
|
| 104 | + if ($type === 'number') { |
|
| 105 | + $html = '<input data-detail_id="'.$detail->id.'" type="number" class="form-control mongifield" id="number_'.$detail->id.'">'; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if($type === 'textarea'){ |
|
| 109 | - $html = '<textarea data-detail_id="'.$detail->id .'" class="form-control mongifield" id="textarea_'.$detail->id.'"></textarea>'; |
|
| 108 | + if ($type === 'textarea') { |
|
| 109 | + $html = '<textarea data-detail_id="'.$detail->id.'" class="form-control mongifield" id="textarea_'.$detail->id.'"></textarea>'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $html; |