@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('product_item_details', function (Blueprint $table) { |
|
| 16 | + Schema::create('product_item_details', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->unsignedBigInteger('product_item_id'); |
| 19 | 19 | $table->unsignedBigInteger('product_detail_id'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('configuration_field_values', function (Blueprint $table) { |
|
| 16 | + Schema::create('configuration_field_values', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->unsignedBigInteger('configuration_field_id'); |
| 19 | 19 | $table->string('value'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('configuration_fields', function (Blueprint $table) { |
|
| 16 | + Schema::create('configuration_fields', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->string('name'); |
| 19 | 19 | $table->unsignedBigInteger('category_id'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('product_items', function (Blueprint $table) { |
|
| 16 | + Schema::create('product_items', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->unsignedBigInteger('product_id'); |
| 19 | 19 | $table->text('img')->nullable(); |
@@ -8,25 +8,25 @@ |
||
| 8 | 8 | use Mongi\Mongicommerce\Http\Controllers\admin\DashboardController; |
| 9 | 9 | |
| 10 | 10 | //BackEnd Pages |
| 11 | -Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard'); |
|
| 12 | -Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new'); |
|
| 13 | -Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details'); |
|
| 11 | +Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard'); |
|
| 12 | +Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new'); |
|
| 13 | +Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details'); |
|
| 14 | 14 | //products |
| 15 | -Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new'); |
|
| 15 | +Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | //Post |
| 22 | -Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 23 | -Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories'); |
|
| 24 | -Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 22 | +Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 23 | +Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories'); |
|
| 24 | +Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 25 | 25 | |
| 26 | 26 | //details |
| 27 | -Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail'); |
|
| 28 | -Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details'); |
|
| 27 | +Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail'); |
|
| 28 | +Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details'); |
|
| 29 | 29 | |
| 30 | 30 | //configuration |
| 31 | -Route::post('/admin/post/create/configuration',[AdminConfigurationFieldController::class,'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
| 32 | -Route::post('/admin/post/get/configuration',[AdminConfigurationFieldController::class,'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
| 31 | +Route::post('/admin/post/create/configuration', [AdminConfigurationFieldController::class, 'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
| 32 | +Route::post('/admin/post/get/configuration', [AdminConfigurationFieldController::class, 'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
@@ -12,16 +12,16 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class AdminDetailController extends Controller |
| 14 | 14 | { |
| 15 | - public function page(){ |
|
| 15 | + public function page() { |
|
| 16 | 16 | $types_details = config('mongicommerce.details'); |
| 17 | 17 | $configuration_field = config('mongicommerce.description_field'); |
| 18 | - return view('mongicommerce::admin.pages.details.create_details',[ |
|
| 18 | + return view('mongicommerce::admin.pages.details.create_details', [ |
|
| 19 | 19 | 'types' =>$types_details, |
| 20 | 20 | 'configuration_field' => $configuration_field |
| 21 | 21 | ]); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function setNewDetail(Request $r){ |
|
| 24 | + public function setNewDetail(Request $r) { |
|
| 25 | 25 | |
| 26 | 26 | $r->validate([ |
| 27 | 27 | 'name' => 'required', |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | $detail->name = $name; |
| 41 | 41 | $detail->save(); |
| 42 | 42 | |
| 43 | - if($type === 'select' || $type === 'checkbox' || $type === 'radio'){ |
|
| 44 | - foreach ($values as $value){ |
|
| 43 | + if ($type === 'select' || $type === 'checkbox' || $type === 'radio') { |
|
| 44 | + foreach ($values as $value) { |
|
| 45 | 45 | $datails_value = new DetailValue(); |
| 46 | 46 | $datails_value->detail_id = $detail->id; |
| 47 | 47 | $datails_value->value = $value; |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public function getDetails(Request $r){ |
|
| 57 | + public function getDetails(Request $r) { |
|
| 58 | 58 | $category_id = $r->get('category_id'); |
| 59 | - $details = Detail::where('category_id',$category_id)->get(); |
|
| 59 | + $details = Detail::where('category_id', $category_id)->get(); |
|
| 60 | 60 | $d = []; |
| 61 | - foreach ($details as $detail){ |
|
| 61 | + foreach ($details as $detail) { |
|
| 62 | 62 | $d[] = [ |
| 63 | 63 | 'name' => $detail->name, |
| 64 | 64 | 'type' => $detail->type, |
| 65 | 65 | 'values' => $detail->values, |
| 66 | - 'html' => $this->generateDetailHtml($detail,$detail->values) |
|
| 66 | + 'html' => $this->generateDetailHtml($detail, $detail->values) |
|
| 67 | 67 | ]; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -71,36 +71,36 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function generateDetailHtml($detail,$values){ |
|
| 74 | + public function generateDetailHtml($detail, $values) { |
|
| 75 | 75 | $type = $detail->type; |
| 76 | 76 | $html = ''; |
| 77 | 77 | |
| 78 | - if($type === 'select'){ |
|
| 78 | + if ($type === 'select') { |
|
| 79 | 79 | $html = ''; |
| 80 | - $html .= '<select data-detail_id="'.$detail->id .'" class="form-control mongifield">'; |
|
| 80 | + $html .= '<select data-detail_id="'.$detail->id.'" class="form-control mongifield">'; |
|
| 81 | 81 | $html .= '<option value="">Seleziona</option>'; |
| 82 | - foreach($values as $value){ |
|
| 82 | + foreach ($values as $value) { |
|
| 83 | 83 | $html .= '<option value="'.$value->id.'">'.$value->value.'</option>'; |
| 84 | 84 | } |
| 85 | 85 | $html .= '</select>'; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($type === 'checkbox'){ |
|
| 88 | + if ($type === 'checkbox') { |
|
| 89 | 89 | $html = ''; |
| 90 | 90 | |
| 91 | - foreach($values as $value){ |
|
| 91 | + foreach ($values as $value) { |
|
| 92 | 92 | $html .= '<div class="custom-control custom-checkbox mongifield">'; |
| 93 | - $html .= '<input data-detail_id="'.$detail->id .'" type="checkbox" class="custom-control-input mongifield" id="defaultUnchecked_'.$value->id.'">'; |
|
| 93 | + $html .= '<input data-detail_id="'.$detail->id.'" type="checkbox" class="custom-control-input mongifield" id="defaultUnchecked_'.$value->id.'">'; |
|
| 94 | 94 | $html .= '<label class="custom-control-label" for="defaultUnchecked_'.$value->id.'">'.$value->value.'</label>'; |
| 95 | 95 | $html .= '</div>'; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if($type === 'radio'){ |
|
| 99 | + if ($type === 'radio') { |
|
| 100 | 100 | $html = ''; |
| 101 | - foreach($values as $value){ |
|
| 101 | + foreach ($values as $value) { |
|
| 102 | 102 | $html .= '<div class="custom-control custom-radio mongifield">'; |
| 103 | - $html .= '<input name="radio_'.$value->detail_id.'" data-detail_id="'.$detail->id .'" type="radio" class="custom-control-input mongifield" id="defaultradio_'.$value->id.'">'; |
|
| 103 | + $html .= '<input name="radio_'.$value->detail_id.'" data-detail_id="'.$detail->id.'" type="radio" class="custom-control-input mongifield" id="defaultradio_'.$value->id.'">'; |
|
| 104 | 104 | $html .= '<label class="custom-control-label" for="defaultradio_'.$value->id.'">'.$value->value.'</label>'; |
| 105 | 105 | $html .= '</div>'; |
| 106 | 106 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class AdminConfigurationFieldController extends Controller |
| 14 | 14 | { |
| 15 | - public function setNewConfiguration(Request $r){ |
|
| 15 | + public function setNewConfiguration(Request $r) { |
|
| 16 | 16 | |
| 17 | 17 | $r->validate([ |
| 18 | 18 | 'name' => 'required', |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | return response()->json(true); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function getConfigurationFields(Request $r){ |
|
| 36 | + public function getConfigurationFields(Request $r) { |
|
| 37 | 37 | $category_id = $r->get('category_id'); |
| 38 | - $configurationFields = ConfigurationField::where('category_id',$category_id)->get(); |
|
| 38 | + $configurationFields = ConfigurationField::where('category_id', $category_id)->get(); |
|
| 39 | 39 | $d = []; |
| 40 | - foreach ($configurationFields as $field){ |
|
| 40 | + foreach ($configurationFields as $field) { |
|
| 41 | 41 | $d[] = [ |
| 42 | 42 | 'name' => $field->name, |
| 43 | 43 | 'type' => $field->type, |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function generateConfigurationFieldHtml($field){ |
|
| 51 | + public function generateConfigurationFieldHtml($field) { |
|
| 52 | 52 | $type = $field->type; |
| 53 | 53 | $html = ''; |
| 54 | - if($type === 'textarea'){ |
|
| 54 | + if ($type === 'textarea') { |
|
| 55 | 55 | $html = ''; |
| 56 | - $html .= '<textarea data-detail_id="'.$field->id .'" class="form-control mongifield"></textarea>'; |
|
| 57 | - }else{ |
|
| 58 | - $html .= '<input type="'.$type.'" data-detail_id="'.$field->id .'" class="form-control mongifield">'; |
|
| 56 | + $html .= '<textarea data-detail_id="'.$field->id.'" class="form-control mongifield"></textarea>'; |
|
| 57 | + } else { |
|
| 58 | + $html .= '<input type="'.$type.'" data-detail_id="'.$field->id.'" class="form-control mongifield">'; |
|
| 59 | 59 | } |
| 60 | 60 | return $html; |
| 61 | 61 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | if($type === 'textarea'){ |
| 55 | 55 | $html = ''; |
| 56 | 56 | $html .= '<textarea data-detail_id="'.$field->id .'" class="form-control mongifield"></textarea>'; |
| 57 | - }else{ |
|
| 57 | + } else{ |
|
| 58 | 58 | $html .= '<input type="'.$type.'" data-detail_id="'.$field->id .'" class="form-control mongifield">'; |
| 59 | 59 | } |
| 60 | 60 | return $html; |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | { |
| 12 | 12 | use HasFactory; |
| 13 | 13 | |
| 14 | - public function value(){ |
|
| 15 | - return $this->belongsTo(ConfigurationFieldValue::class,'configuration_field_id'); |
|
| 14 | + public function value() { |
|
| 15 | + return $this->belongsTo(ConfigurationFieldValue::class, 'configuration_field_id'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |