Test Failed
Push — master ( c94a90...befccc )
by Gianluca
06:01
created
src/Http/Controllers/admin/AdminNewProductController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
 class AdminNewProductController extends Controller
15 15
 {
16
-    public function page(){
16
+    public function page() {
17 17
         return view('mongicommerce::admin.pages.products.new_product');
18 18
     }
19 19
 
20
-    public function createNewProduct(Request $r){
20
+    public function createNewProduct(Request $r) {
21 21
 
22 22
         $r->validate([
23 23
             'product_name' => 'required',
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
         $product->category_id = $category_id;
39 39
         $product->save();
40 40
 
41
-        $base64_str = substr($get_image, strpos($get_image, ",")+1);
41
+        $base64_str = substr($get_image, strpos($get_image, ",") + 1);
42 42
         $image = base64_decode($base64_str);
43 43
         $destinationPath = public_path().'/uploads/products_img/'.$product->id.'/';
44 44
         $destinationPathDB = url('/').'/uploads/products_img/'.$product->id.'/';
45 45
 
46
-        if(!File::isDirectory($destinationPath)){
46
+        if (!File::isDirectory($destinationPath)) {
47 47
             File::makeDirectory($destinationPath, $mode = 0777, true, true);
48 48
         }
49 49
         $image_name = time().'.'.'jpeg';
Please login to merge, or discard this patch.
database/migrations/2020_12_02_085340_create_product_items_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('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('image')->nullable();
Please login to merge, or discard this patch.
src/Libraries/Template.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 
16 16
 class Template
17 17
 {
18
-    public static function getStructureCategories(){
18
+    public static function getStructureCategories() {
19 19
 
20 20
         $categories = Category::with('children')->whereNull('parent_id')->get();
21 21
         $tree = [];
22
-        foreach($categories as $category){
22
+        foreach ($categories as $category) {
23 23
             $tree[] = [
24 24
                 'id' => $category->id,
25 25
                 'text' => $category->name,
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
         return $tree;
31 31
     }
32 32
 
33
-    private static function recursiveChildren($childrens){
33
+    private static function recursiveChildren($childrens) {
34 34
         $childs = [];
35
-        foreach ($childrens as $children){
35
+        foreach ($childrens as $children) {
36 36
             $childs[] = [
37 37
                 'id' => $children->id,
38 38
                 'text' => $children->name,
@@ -48,51 +48,51 @@  discard block
 block discarded – undo
48 48
      * @param Int $id
49 49
      * @return Product
50 50
      */
51
-    public static function getProducts($id = null){
52
-        if($id === null){
51
+    public static function getProducts($id = null) {
52
+        if ($id === null) {
53 53
             $products = Product::all();
54
-        }else{
55
-            if(Category::find($id)){
54
+        } else {
55
+            if (Category::find($id)) {
56 56
                 $belong_to_this_category = Category::find($id)->children->pluck('id')->toArray();
57 57
                 $result = array_merge($belong_to_this_category, [0 =>$id]);
58
-                $products = Product::whereIn('category_id',$result)->get();
59
-            }else{
58
+                $products = Product::whereIn('category_id', $result)->get();
59
+            } else {
60 60
                 $products = [];
61 61
             }
62 62
         }
63 63
         return $products;
64 64
     }
65 65
 
66
-    public static function getDetailsFields(Product $product){
66
+    public static function getDetailsFields(Product $product) {
67 67
         $element = '<div class="row">';
68 68
 
69
-        foreach($product->details->groupBy('product_detail_id') as $key => $details){
69
+        foreach ($product->details->groupBy('product_detail_id') as $key => $details) {
70 70
 
71
-            $element.= self::generateDetailHtml(Detail::find($key),$details->groupBy('product_detail_value_id'),$product->id);
71
+            $element .= self::generateDetailHtml(Detail::find($key), $details->groupBy('product_detail_value_id'), $product->id);
72 72
         }
73
-        $element.= '<button class="btn btn-primary mt-3">Salva nel carrello</button>';
74
-        $element.= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
73
+        $element .= '<button class="btn btn-primary mt-3">Salva nel carrello</button>';
74
+        $element .= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
75 75
         $element .= '</div>';
76 76
         return $element;
77 77
     }
78 78
 
79
-    public static function generateDetailHtml($detail,$values,$product_id){
79
+    public static function generateDetailHtml($detail, $values, $product_id) {
80 80
 
81 81
         $type = $detail->type;
82 82
         $html = '';
83 83
         $filters = Session()->get('filters');
84
-        if($type === 'select'){
84
+        if ($type === 'select') {
85 85
             $html = '<label>'.$detail->name.'</label>';
86
-            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id .'" class="form-control mongifield_into_product">';
86
+            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id.'" class="form-control mongifield_into_product">';
87 87
             $html .= '<option value="">Seleziona</option>';
88 88
             $selected = '';
89 89
 
90
-            foreach ($values as $detail_value_id =>$value){
90
+            foreach ($values as $detail_value_id =>$value) {
91 91
 
92
-                if(isset($filters[$detail->id])){
93
-                    if($filters[$detail->id] == $detail_value_id){
92
+                if (isset($filters[$detail->id])) {
93
+                    if ($filters[$detail->id] == $detail_value_id) {
94 94
                         $selected = 'selected';
95
-                    }else{
95
+                    } else {
96 96
                         $selected = '';
97 97
                     }
98 98
                 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
     public static function getProducts($id = null){
52 52
         if($id === null){
53 53
             $products = Product::all();
54
-        }else{
54
+        } else{
55 55
             if(Category::find($id)){
56 56
                 $belong_to_this_category = Category::find($id)->children->pluck('id')->toArray();
57 57
                 $result = array_merge($belong_to_this_category, [0 =>$id]);
58 58
                 $products = Product::whereIn('category_id',$result)->get();
59
-            }else{
59
+            } else{
60 60
                 $products = [];
61 61
             }
62 62
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                 if(isset($filters[$detail->id])){
93 93
                     if($filters[$detail->id] == $detail_value_id){
94 94
                         $selected = 'selected';
95
-                    }else{
95
+                    } else{
96 96
                         $selected = '';
97 97
                     }
98 98
                 }
Please login to merge, or discard this patch.