@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('details', function (Blueprint $table) { |
|
| 16 | + Schema::create('details', 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('detail_values', function (Blueprint $table) { |
|
| 16 | + Schema::create('detail_values', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->unsignedBigInteger('detail_id'); |
| 19 | 19 | $table->string('value'); |
@@ -7,19 +7,19 @@ |
||
| 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/crea/dettagli',[AdminCreateDetailController::class,'page'])->name('admin.details'); |
|
| 13 | -Route::get('/admin/mostra/dettagli',[AdminShowDetailController::class,'page'])->name('admin.show.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/crea/dettagli', [AdminCreateDetailController::class, 'page'])->name('admin.details'); |
|
| 13 | +Route::get('/admin/mostra/dettagli', [AdminShowDetailController::class, 'page'])->name('admin.show.details'); |
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | //Post |
| 19 | -Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 20 | -Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories'); |
|
| 21 | -Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 19 | +Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 20 | +Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories'); |
|
| 21 | +Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 22 | 22 | |
| 23 | 23 | //details |
| 24 | -Route::post('/admin/post/create/detail',[AdminCreateDetailController::class,'setNewDetail'])->name('admin.post.create.detail'); |
|
| 25 | -Route::post('/admin/post/get/details',[AdminShowDetailController::class,'getDetails'])->name('admin.post.get.details'); |
|
| 24 | +Route::post('/admin/post/create/detail', [AdminCreateDetailController::class, 'setNewDetail'])->name('admin.post.create.detail'); |
|
| 25 | +Route::post('/admin/post/get/details', [AdminShowDetailController::class, 'getDetails'])->name('admin.post.get.details'); |
|
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class AdminCreateDetailController 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; |
@@ -10,20 +10,20 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class AdminShowDetailController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | return view('mongicommerce::admin.pages.details.show_details'); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function getDetails(Request $r){ |
|
| 17 | + public function getDetails(Request $r) { |
|
| 18 | 18 | $category_id = $r->get('category_id'); |
| 19 | - $details = Detail::where('category_id',$category_id)->get(); |
|
| 19 | + $details = Detail::where('category_id', $category_id)->get(); |
|
| 20 | 20 | $d = []; |
| 21 | - foreach ($details as $detail){ |
|
| 21 | + foreach ($details as $detail) { |
|
| 22 | 22 | $d[] = [ |
| 23 | 23 | 'name' => $detail->name, |
| 24 | 24 | 'type' => $detail->type, |
| 25 | 25 | 'values' => $detail->values, |
| 26 | - 'html' => $this->generateDetailHtml($detail->type,$detail->values) |
|
| 26 | + 'html' => $this->generateDetailHtml($detail->type, $detail->values) |
|
| 27 | 27 | ]; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -31,21 +31,21 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function generateDetailHtml($type,$values){ |
|
| 35 | - if($type === 'select'){ |
|
| 34 | + public function generateDetailHtml($type, $values) { |
|
| 35 | + if ($type === 'select') { |
|
| 36 | 36 | $html = ''; |
| 37 | 37 | $html .= '<select class="form-control">'; |
| 38 | 38 | $html .= '<option value="">Seleziona</option>'; |
| 39 | - foreach($values as $value){ |
|
| 39 | + foreach ($values as $value) { |
|
| 40 | 40 | $html .= '<option value="'.$value->id.'">'.$value->value.'</option>'; |
| 41 | 41 | } |
| 42 | 42 | $html .= '</select>'; |
| 43 | 43 | return $html; |
| 44 | 44 | } |
| 45 | - if($type === 'checkbox'){ |
|
| 45 | + if ($type === 'checkbox') { |
|
| 46 | 46 | $html = ''; |
| 47 | 47 | |
| 48 | - foreach($values as $value){ |
|
| 48 | + foreach ($values as $value) { |
|
| 49 | 49 | $html .= '<div class="custom-control custom-checkbox">'; |
| 50 | 50 | $html .= '<input type="checkbox" class="custom-control-input" id="defaultUnchecked_'.$value->id.'">'; |
| 51 | 51 | $html .= '<label class="custom-control-label" for="defaultUnchecked_'.$value->id.'">'.$value->value.'</label>'; |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | { |
| 12 | 12 | use HasFactory; |
| 13 | 13 | |
| 14 | - public function values(){ |
|
| 15 | - return $this->hasMany(DetailValue::class,'detail_id'); |
|
| 14 | + public function values() { |
|
| 15 | + return $this->hasMany(DetailValue::class, 'detail_id'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |