Passed
Push — master ( c3c113...578dae )
by Gianluca
06:19
created
src/MongicommerceServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         if ($this->app->runningInConsole()) {
25 25
 
26 26
             $config_file = config_path('mongicommerce.php');
27
-            if(file_exists($config_file)){
27
+            if (file_exists($config_file)) {
28 28
                 File::delete($config_file);
29 29
             }
30 30
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'mongicommerce');
67 67
 
68 68
         // Register the main class to use with the facade
69
-        $this->app->singleton('mongicommerce', function () {
69
+        $this->app->singleton('mongicommerce', function() {
70 70
             return new Mongicommerce;
71 71
         });
72 72
     }
Please login to merge, or discard this patch.
resources/views/admin/template/layout.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -855,7 +855,7 @@
 block discarded – undo
855 855
                     <?php $link = "" ?>
856 856
                     @for($i = 1; $i <= count(Request::segments()); $i++)
857 857
                         @if($i < count(Request::segments()) & $i > 0)
858
-                            <?php $link .= "/" . Request::segment($i); ?>
858
+                            <?php $link .= "/".Request::segment($i); ?>
859 859
                             <li class="breadcrumb-item active"> <a href="<?= $link ?>">{{ ucwords(str_replace('-',' ',Request::segment($i)))}}</a> </li> >
860 860
                         @else {{ucwords(str_replace('-',' ',Request::segment($i)))}}
861 861
                         @endif
Please login to merge, or discard this patch.
database/migrations/2020_12_02_085259_create_categories_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('categories', function (Blueprint $table) {
16
+        Schema::create('categories', function(Blueprint $table) {
17 17
             $table->id();
18 18
             $table->string('name');
19 19
             $table->string('description')->nullable();
Please login to merge, or discard this patch.
database/migrations/2020_12_02_085260_create_details_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
database/migrations/2020_12_02_085261_create_detail_values_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminCategoryController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 
11 11
 class AdminCategoryController extends Controller
12 12
 {
13
-    public function page(){
13
+    public function page() {
14 14
         return view('mongicommerce::admin.pages.category.new_category');
15 15
     }
16 16
 
17
-    public function setNewCategory(Request $r){
17
+    public function setNewCategory(Request $r) {
18 18
         $r->validate([
19 19
             'name' => 'required',
20 20
             'description' => 'max:255'
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
         $category->save();
30 30
     }
31 31
 
32
-    public function getCategories(){
32
+    public function getCategories() {
33 33
         $data = $this->getCategoryTree();
34 34
         return Response()->json($data);
35 35
     }
36 36
 
37 37
     function getCategoryTree($parent_id = null, $spacing = '', $tree_array = array()) {
38
-        $categories = Category::select('id', 'name', 'parent_id')->where('parent_id' ,'=', $parent_id)->orderBy('parent_id')->get();
39
-        foreach ($categories as $item){
40
-            $tree_array[] = ['id' => $item->id, 'name' =>$spacing . $item->name] ;
41
-            $tree_array = $this->getCategoryTree($item->id, $spacing . '- ', $tree_array);
38
+        $categories = Category::select('id', 'name', 'parent_id')->where('parent_id', '=', $parent_id)->orderBy('parent_id')->get();
39
+        foreach ($categories as $item) {
40
+            $tree_array[] = ['id' => $item->id, 'name' =>$spacing.$item->name];
41
+            $tree_array = $this->getCategoryTree($item->id, $spacing.'- ', $tree_array);
42 42
         }
43 43
         return $tree_array;
44 44
     }
45 45
 
46
-    public function getStructureCategories(){
46
+    public function getStructureCategories() {
47 47
 
48 48
         $categories = Category::with('children')->whereNull('parent_id')->get();
49 49
         $tree = [];
50
-        foreach($categories as $category){
50
+        foreach ($categories as $category) {
51 51
                 $tree[] = [
52 52
                     'id' => $category->id,
53 53
                     'text' => $category->name,
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
         return response()->json($tree);
59 59
     }
60 60
 
61
-    private function recursiveChildren($childrens){
61
+    private function recursiveChildren($childrens) {
62 62
         $childs = [];
63
-        foreach ($childrens as $children){
63
+        foreach ($childrens as $children) {
64 64
             $childs[] = [
65 65
                 'id' => $children->id,
66 66
                 'text' => $children->name,
Please login to merge, or discard this patch.
src/Models/Detail.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 use Mongi\Mongicommerce\Http\Controllers\admin\DashboardController;
7 7
 
8 8
 //BackEnd Pages
9
-Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard');
10
-Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new');
11
-Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details');
9
+Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard');
10
+Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new');
11
+Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details');
12 12
 
13 13
 
14 14
 
15 15
 
16 16
 
17 17
 //Post
18
-Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree');
19
-Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories');
20
-Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category');
18
+Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree');
19
+Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories');
20
+Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category');
21 21
 
22 22
 //details
23
-Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail');
24
-Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details');
23
+Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail');
24
+Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details');
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminDetailController.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,23 +63,23 @@  discard block
 block discarded – undo
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 71
             $html .= '<select class="form-control">';
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">';
84 84
                 $html .= '<input type="checkbox" class="custom-control-input" id="defaultUnchecked_'.$value->id.'">';
85 85
                 $html .= '<label class="custom-control-label" for="defaultUnchecked_'.$value->id.'">'.$value->value.'</label>';
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
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">';
94 94
                 $html .= '<input name="radio_'.$value->detail_id.'"  type="radio" class="custom-control-input" id="defaultradio_'.$value->id.'">';
95 95
                 $html .= '<label class="custom-control-label" for="defaultradio_'.$value->id.'">'.$value->value.'</label>';
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
             }
98 98
         }
99 99
 
100
-        if($type === 'text'){
101
-            $html = '<input  type="text" class="form-control" id="text_' . $detail->id . '">';
100
+        if ($type === 'text') {
101
+            $html = '<input  type="text" class="form-control" id="text_'.$detail->id.'">';
102 102
         }
103 103
 
104
-        if($type === 'number'){
105
-            $html = '<input  type="number" class="form-control" id="number_' . $detail->id . '">';
104
+        if ($type === 'number') {
105
+            $html = '<input  type="number" class="form-control" id="number_'.$detail->id.'">';
106 106
         }
107 107
 
108
-        if($type === 'textarea'){
108
+        if ($type === 'textarea') {
109 109
             $html = '<textarea class="form-control" id="textarea_'.$detail->id.'"></textarea>';
110 110
         }
111 111
 
Please login to merge, or discard this patch.