From c68f28aa11c969a53ea16093bfe6a6ed1782d766 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Mon, 30 Sep 2024 01:15:42 +0800 Subject: [PATCH 01/19] updated prod --- Dockerfile | 0 .../teamstore/TeamStoreController.php | 24 ++++++++++ composer.json | 5 +- docker-compose.yml | 0 favicon.ico | Bin nginx/conf.d/app.conf | 0 php/local.ini | 0 public/api/canada.json | 0 public/api/usa.json | 0 public/api/usaCities.old.json | 0 public/assets/css/jquery-ui.css | 0 public/assets/files/Terms of Use.pdf | Bin public/assets/js/jquery-ui.js | 0 public/images/MERCHBAY-LOGO.png | Bin public/images/merchbay-black.png | Bin public/images/merchbay-white.png | Bin .../views/designer/vue_designer.blade.php | 0 resources/views/emails/contact_us.blade.php | 0 resources/views/emails/orders.blade.php | 18 +++++++ resources/views/errors/404.blade.php | 0 resources/views/merchbay/cart.blade.php | 20 ++++++++ resources/views/merchbay/not_found.blade.php | 0 .../views/merchbay/privacy_policy.blade.php | 0 .../views/merchbay/terms_of_use.blade.php | 0 .../views/merchbay/track_order.blade.php | 0 .../views/paypal/payment_success.blade.php | 0 .../forms/number-size-form.blade.php | 45 ++++++++++++++++++ .../roster-name-number-size-form.blade.php | 0 .../views/user-layouts/add_item.blade.php | 1 + .../views/user-layouts/buy_design.blade.php | 3 +- .../user-layouts/order-details-body.blade.php | 14 ++++++ .../user-layouts/order_details.blade.php | 15 ++++++ .../views/user-layouts/sell_design.blade.php | 1 + .../user-layouts/view-store-item.blade.php | 1 + storage/keys/crewsportswear_app.key | 0 storage/keys/crewsportswear_app.ppk | 0 36 files changed, 145 insertions(+), 2 deletions(-) mode change 100644 => 100755 Dockerfile mode change 100644 => 100755 docker-compose.yml mode change 100644 => 100755 favicon.ico mode change 100644 => 100755 nginx/conf.d/app.conf mode change 100644 => 100755 php/local.ini mode change 100644 => 100755 public/api/canada.json mode change 100644 => 100755 public/api/usa.json mode change 100644 => 100755 public/api/usaCities.old.json mode change 100644 => 100755 public/assets/css/jquery-ui.css mode change 100644 => 100755 public/assets/files/Terms of Use.pdf mode change 100644 => 100755 public/assets/js/jquery-ui.js mode change 100644 => 100755 public/images/MERCHBAY-LOGO.png mode change 100644 => 100755 public/images/merchbay-black.png mode change 100644 => 100755 public/images/merchbay-white.png mode change 100644 => 100755 resources/views/designer/vue_designer.blade.php mode change 100644 => 100755 resources/views/emails/contact_us.blade.php mode change 100644 => 100755 resources/views/errors/404.blade.php mode change 100644 => 100755 resources/views/merchbay/not_found.blade.php mode change 100644 => 100755 resources/views/merchbay/privacy_policy.blade.php mode change 100644 => 100755 resources/views/merchbay/terms_of_use.blade.php mode change 100644 => 100755 resources/views/merchbay/track_order.blade.php mode change 100644 => 100755 resources/views/paypal/payment_success.blade.php create mode 100755 resources/views/teamstore-sublayouts/forms/number-size-form.blade.php mode change 100644 => 100755 resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php mode change 100644 => 100755 storage/keys/crewsportswear_app.key mode change 100644 => 100755 storage/keys/crewsportswear_app.ppk diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/teamstore/TeamStoreController.php b/app/Http/Controllers/teamstore/TeamStoreController.php index 3d588ac..1e479e9 100755 --- a/app/Http/Controllers/teamstore/TeamStoreController.php +++ b/app/Http/Controllers/teamstore/TeamStoreController.php @@ -499,6 +499,30 @@ class TeamStoreController extends Controller 'ShippingCostId' => $shipping_cost_id ); } + } elseif ($product_form == "number-size-form") { + + // $order_names = $post['order_names']; + $order_number = $post['order_number']; + $order_size = $post['order_size']; + + foreach ($order_size as $key => $val) { + $items[] = array( + 'ProductId' => $product_id, + 'StoreURL' => $store_url, + 'StoreId' => $store_id, + 'FormUsed' => $product_form, + 'CartKey' => $cartKey, + 'DesignCode' => $design_code, + 'ProductURL' => $ProductURL, + 'ProductName' => $product_name, + 'Name' => $product_name, + 'Size' => $order_size[$key], + 'Number' => $order_number[$key], + 'Price' => $ProductPrice, + 'Quantity' => 1, + 'ShippingCostId' => $shipping_cost_id + ); + } } elseif ($product_form == "number-form") { $order_number = $post['order_number']; diff --git a/composer.json b/composer.json index f3fff5b..6a2cf3a 100755 --- a/composer.json +++ b/composer.json @@ -46,6 +46,9 @@ ] }, "config": { - "preferred-install": "dist" + "preferred-install": "dist", + "allow-plugins": { + "kylekatarnls/update-helper": true + } } } diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 diff --git a/favicon.ico b/favicon.ico old mode 100644 new mode 100755 diff --git a/nginx/conf.d/app.conf b/nginx/conf.d/app.conf old mode 100644 new mode 100755 diff --git a/php/local.ini b/php/local.ini old mode 100644 new mode 100755 diff --git a/public/api/canada.json b/public/api/canada.json old mode 100644 new mode 100755 diff --git a/public/api/usa.json b/public/api/usa.json old mode 100644 new mode 100755 diff --git a/public/api/usaCities.old.json b/public/api/usaCities.old.json old mode 100644 new mode 100755 diff --git a/public/assets/css/jquery-ui.css b/public/assets/css/jquery-ui.css old mode 100644 new mode 100755 diff --git a/public/assets/files/Terms of Use.pdf b/public/assets/files/Terms of Use.pdf old mode 100644 new mode 100755 diff --git a/public/assets/js/jquery-ui.js b/public/assets/js/jquery-ui.js old mode 100644 new mode 100755 diff --git a/public/images/MERCHBAY-LOGO.png b/public/images/MERCHBAY-LOGO.png old mode 100644 new mode 100755 diff --git a/public/images/merchbay-black.png b/public/images/merchbay-black.png old mode 100644 new mode 100755 diff --git a/public/images/merchbay-white.png b/public/images/merchbay-white.png old mode 100644 new mode 100755 diff --git a/resources/views/designer/vue_designer.blade.php b/resources/views/designer/vue_designer.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/emails/contact_us.blade.php b/resources/views/emails/contact_us.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/emails/orders.blade.php b/resources/views/emails/orders.blade.php index ea78987..25c0d88 100755 --- a/resources/views/emails/orders.blade.php +++ b/resources/views/emails/orders.blade.php @@ -540,6 +540,13 @@ Price Quantity + @elseif($item->FormUsed == 'number-size-form') + + Number + Size + Price + Quantity + @else @endif @@ -666,6 +673,17 @@ {{ $sub_item->Quantity }} + @elseif($item->FormUsed == 'number-size-form') + + {{ $sub_item->Number }} + + {{ $sub_item->Size }} + + {{ $sub_item->Price }} + + {{ $sub_item->Quantity }} + + @else @endif @endif diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/merchbay/cart.blade.php b/resources/views/merchbay/cart.blade.php index 7d0125a..e901282 100755 --- a/resources/views/merchbay/cart.blade.php +++ b/resources/views/merchbay/cart.blade.php @@ -174,6 +174,15 @@ Quantity + @elseif($item->FormUsed == 'number-size-form') + + Number + Size + Price + Quantity + + + @else @endif @@ -296,6 +305,17 @@ href="{{ url('removeitem') }}/{{ $sub_item->Id }}"> + @elseif($item->FormUsed == 'number-size-form') + + {{ $sub_item->Number }} + {{ $sub_item->Size }} + {{ $sub_item->Price . ' ' . $store_array[0]->StoreCurrency }} + + {{ $sub_item->Quantity }} + + @else @endif @endif diff --git a/resources/views/merchbay/not_found.blade.php b/resources/views/merchbay/not_found.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/merchbay/privacy_policy.blade.php b/resources/views/merchbay/privacy_policy.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/merchbay/terms_of_use.blade.php b/resources/views/merchbay/terms_of_use.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/merchbay/track_order.blade.php b/resources/views/merchbay/track_order.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/paypal/payment_success.blade.php b/resources/views/paypal/payment_success.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/teamstore-sublayouts/forms/number-size-form.blade.php b/resources/views/teamstore-sublayouts/forms/number-size-form.blade.php new file mode 100755 index 0000000..c548c72 --- /dev/null +++ b/resources/views/teamstore-sublayouts/forms/number-size-form.blade.php @@ -0,0 +1,45 @@ + +
+ + + + + {{-- --}} + + + + + + + + {{-- --}} + + + + + +
NameNumberSize
+ + + + + + + + + +
+
+
+
+ \ No newline at end of file diff --git a/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php b/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/user-layouts/add_item.blade.php b/resources/views/user-layouts/add_item.blade.php index f75d5c6..a13b850 100755 --- a/resources/views/user-layouts/add_item.blade.php +++ b/resources/views/user-layouts/add_item.blade.php @@ -102,6 +102,7 @@ + diff --git a/resources/views/user-layouts/buy_design.blade.php b/resources/views/user-layouts/buy_design.blade.php index 50e6a16..7667820 100755 --- a/resources/views/user-layouts/buy_design.blade.php +++ b/resources/views/user-layouts/buy_design.blade.php @@ -125,7 +125,8 @@ - + + diff --git a/resources/views/user-layouts/order-details-body.blade.php b/resources/views/user-layouts/order-details-body.blade.php index 5000aef..46983c5 100755 --- a/resources/views/user-layouts/order-details-body.blade.php +++ b/resources/views/user-layouts/order-details-body.blade.php @@ -114,6 +114,13 @@ Price Quantity + @elseif($array_item[0]->FormUsed=="number-size-form") + + Number + Size + Price + Quantity + @else @endif @@ -195,6 +202,13 @@ {{ $array_item[0]->Price . ' ' . $store_array[0]->StoreCurrency }} {{ $array_item[0]->Quantity }} + @elseif($array_item[0]->FormUsed=="number-size-form") + + {{ $array_item[0]->Number }} + {{ $array_item[0]->Size }} + {{ $array_item[0]->Price . ' ' . $store_array[0]->StoreCurrency }} + {{ $array_item[0]->Quantity }} + @else @endif diff --git a/resources/views/user-layouts/order_details.blade.php b/resources/views/user-layouts/order_details.blade.php index 440533a..6008e73 100755 --- a/resources/views/user-layouts/order_details.blade.php +++ b/resources/views/user-layouts/order_details.blade.php @@ -158,6 +158,14 @@ Quantity + @elseif($item->FormUsed=="number-size-form") + + Number + Size + Price + Quantity + + @else @endif @@ -219,6 +227,13 @@ {{ $sub_item->Price . ' ' . $array_payment_details[0]->Currency }} {{ $sub_item->Quantity }} + @elseif($item->FormUsed=="number-size-form") + + {{ $sub_item->Number }} + {{ $sub_item->Size }} + {{ $sub_item->Price . ' ' . $array_payment_details[0]->Currency }} + {{ $sub_item->Quantity }} + @else @endif diff --git a/resources/views/user-layouts/sell_design.blade.php b/resources/views/user-layouts/sell_design.blade.php index 2d38985..798c681 100755 --- a/resources/views/user-layouts/sell_design.blade.php +++ b/resources/views/user-layouts/sell_design.blade.php @@ -127,6 +127,7 @@ +
diff --git a/resources/views/user-layouts/view-store-item.blade.php b/resources/views/user-layouts/view-store-item.blade.php index 00050c9..5b82883 100755 --- a/resources/views/user-layouts/view-store-item.blade.php +++ b/resources/views/user-layouts/view-store-item.blade.php @@ -129,6 +129,7 @@ + diff --git a/storage/keys/crewsportswear_app.key b/storage/keys/crewsportswear_app.key old mode 100644 new mode 100755 diff --git a/storage/keys/crewsportswear_app.ppk b/storage/keys/crewsportswear_app.ppk old mode 100644 new mode 100755 -- 2.49.1 From 54278c568da8aa78d71819f950301308f33e78e3 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Tue, 5 Nov 2024 05:33:47 +0800 Subject: [PATCH 02/19] added roster config --- .DS_Store | Bin 0 -> 10244 bytes app/Http/Controllers/user/UserController.php | 80 +- app/Http/routes.php | 5 + app/Models/user/UserModel.php | 42 +- .../views/user-layouts/add_item.blade.php | 8 +- .../user-layouts/user_template.blade.php | 5 +- .../user-layouts/view-store-item.blade.php | 868 +++++++++++++----- 7 files changed, 750 insertions(+), 258 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..537b1561a4c517432ec86b6e1e0e484ad6768089 GIT binary patch literal 10244 zcmeHMy^B*p5TDI`->LY4ASXf!K`ji5AlOBTh+^egScrO;obe;M7cLh$EhHcoo*%sm zRyI}&He#=}|A68Zf*=T@jg|gpcXOF}Z{JxdD!Z^dFK>UdJM){_eQ#fg$QfE>haTX4OeFCdFvmc8sci5?W=R3V+J@kb2f z)N#M)ab+*NPC9im{_tV^%*LNkjGZ0h7cHDj*~!>O1|kDl2KekgNF}P%MOskj_s^$p z$i8M$smwHz8QdFvb9U?O^2yf+b$@Nu{?-NYZQ#cGU);$G6S~o^BU^4-}jXKY^Y7MjP*BZ(< z8b1P!z_>Yn29f=U2%iH;_1LADe|@nkRyf1;})+6$;Ns9;LlZS(k% z$m0xN+dlXtG-i(dnXz)RJcCnyP?`PM2tRC$Y^-;uqFyNSz5pdm8)EMIZZ;yV5h+9Mf8L>R|Mi%@xezvNNT{`6ac+F!mhpd9(<8i!P*B zsm(H}F$6sC(Q~w@$L6@2bt0|;sUteHA6AH78OsOv5A1k(#_pyH(a*#%LdVa(d#!;# z)4aye)_Z(pS1TcA%I<*>4;-ZsN_$4T;F;IY@oJ?v=#lRYcr)Rw!g^}Kmnxza$Un{s zWo1vRgLvV&3a!O#)*57m(i+Ab9jx94XP%BS=R-bLvSB_>-T@nGEXm2uPhWaZq!gyl zOddw^Q`pkQGC*^w7Qg{Np|MId12&&l zK`ZZ#LBkNfZ$HQ52Y-&=>F?Q>WPe@uvg@Q(hn`i3{6l{R;Gi1M|MCqse7cu! U++l=#d-ebP#PdJVKXCs436rj{lmGw# literal 0 HcmV?d00001 diff --git a/app/Http/Controllers/user/UserController.php b/app/Http/Controllers/user/UserController.php index 6a6ec7f..4eda98a 100755 --- a/app/Http/Controllers/user/UserController.php +++ b/app/Http/Controllers/user/UserController.php @@ -348,14 +348,16 @@ class UserController extends Controller $newTeamStoreModel = new TeamStoreModel; $product_array = $newTeamStoreModel->selectTeamStoreProducts('ProductURL', $url); + $roster = $newUserModel->getRoster($product_array[0]->Id); $thumbnails_array = $newTeamStoreModel->getThumbnails($product_array[0]->Id); $available_size = explode(",", $product_array[0]->AvailableSizes); $shipping_cost = $newUserModel->selectShippingCost(); - return view('user-layouts.view-store-item')->with('product_array', $product_array) ->with('available_size', $available_size) ->with('thumbnails_array', $thumbnails_array) - ->with('shipping_cost', $shipping_cost); + ->with('shipping_cost', $shipping_cost) + ->with('roster', $roster); + } @@ -1344,4 +1346,76 @@ class UserController extends Controller return $array_address_book; } -} + + function roster(Request $request) + { + $UserModel = new UserModel; + $post = $request->all(); + + $response = $UserModel->insertRoster($post['data']); + + if($response) { + return response()->json(array( + 'status' => true, + 'message' => "Roster is successfully saved." + )); + } + + return response()->json(array( + 'status' => false, + 'message' => "Something went wrong. Please try again" + )); + + } + + function deleteRoster(Request $request) { + $UserModel = new UserModel; + $post = $request->all(); + + $response = $UserModel->deleteRoster($post['data']); + + if($response) { + return response()->json(array( + 'status' => true, + 'message' => "Roster is successfully deleted." + )); + } + + return response()->json(array( + 'status' => false, + 'message' => "Something went wrong. Please try again" + )); + + } + + + function rosterUpdate(Request $request) + { + $UserModel = new UserModel; + $post = $request->all(); + + $response = $UserModel->updateRoster($post['data']); + + if($response) { + return response()->json(array( + 'status' => true, + 'message' => "Roster is successfully updated." + )); + } + + return response()->json(array( + 'status' => false, + 'message' => "Something went wrong. Please try again" + )); + + } + + function getCurrentRoster(Request $request) { + $productId = $request->query('product-id'); + $newUserModel = new UserModel; + $roster = $newUserModel->getRoster($productId); + return response()->json($roster); + } + + +} \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 5d1a5d9..1b6af6e 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -149,6 +149,11 @@ Route::group(['middleware' => 'normaluser'], function () { Route::post('user/store-items/personal-design', 'user\UserController@saveNewItemFromDesigner'); + + Route::post('user/roster', 'user\UserController@roster'); + Route::get('user/roster', 'user\UserController@getCurrentRoster'); + Route::post('user/roster-delete', 'user\UserController@deleteRoster'); + Route::post('user/roster-update', 'user\UserController@rosterUpdate'); }); Route::group(['middleware' => 'auth'], function () { diff --git a/app/Models/user/UserModel.php b/app/Models/user/UserModel.php index de14c93..a08bdbc 100755 --- a/app/Models/user/UserModel.php +++ b/app/Models/user/UserModel.php @@ -425,4 +425,44 @@ class UserModel extends Model ->update($data); return $i; } -} + + function insertRoster($data) { + $i = DB::table('roster') + ->insert($data); + return $i; + } + + function getRoster($productId) + { + $i = DB::table('roster') + ->where('ProductId', $productId) + ->get(); + return $i; + } + + function deleteRoster($idArray) + { + $deletedRows = DB::table('roster') + ->whereIn('Id', $idArray) // Replace 'id' with the actual column name if different + ->delete(); + + return $deletedRows; // Returns the number of rows deleted + } + + function updateRoster($data) + { + $updatedRows = 0; + + foreach ($data as $item) { + // Assuming each item contains an 'id' and the fields to update + $id = $item['Id']; + unset($item['Id']); // Remove 'id' from the update data + + $updatedRows += DB::table('roster') + ->where('Id', $id) + ->update($item); + } + + return $updatedRows; // Returns the total number of rows updated + } +} \ No newline at end of file diff --git a/resources/views/user-layouts/add_item.blade.php b/resources/views/user-layouts/add_item.blade.php index a13b850..0da67bb 100755 --- a/resources/views/user-layouts/add_item.blade.php +++ b/resources/views/user-layouts/add_item.blade.php @@ -7,11 +7,12 @@ margin-top:20px; } -
+

- Add Store Item + Add Store Item + {{--

@{{ message }}

--}}

+
+
+
ImageClass != null) checked @endif /> - -
-
- - @endforeach - -
- - - + + + +
+ +
+

+ @{{ title }} + {{ $product_array[0]->ProductName }} +

+ +
+ +
+
+
+
+
+ +
-
-
-
-
-
-
-

- Item Details -

-
-
-
- -
- - -
-
- - -
-
- - -
- -
- - -
-
- - -
-
- - - -
-
- - -
- {{-- {{ var_dump($product_array[0]) }} --}} -
- - -
- -
- - - +
+
+
+
+
    +
  • + + + + +

    + Add Image +

    +
    +
  • + @foreach ($thumbnails_array as $thumbnail) +
  • + + + + +
    +
    + ImageClass != null) checked @endif /> + +
    +
    +
  • + @endforeach +
+
+
+
+ +
+
+
+
+
+
+
+

+ Item Details +

+
+ + +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + + +
+
+ + +
+ {{-- {{ var_dump($product_array[0]) }} --}} +
+ + +
+ +
+ + + +
+
+
+
+ + +
+
+ + + + + + + + + + - - - + + +@endsection -- 2.49.1 From f26c9c274b32ab1aa776958af397c20a4216832b Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Wed, 27 Nov 2024 17:13:00 +0800 Subject: [PATCH 03/19] updated subtotal when orders have voucher --- app/Http/Controllers/paypal/PaypalController.php | 2 +- app/Models/teamstore/TeamStoreModel.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/paypal/PaypalController.php b/app/Http/Controllers/paypal/PaypalController.php index 9c2093b..61d1017 100755 --- a/app/Http/Controllers/paypal/PaypalController.php +++ b/app/Http/Controllers/paypal/PaypalController.php @@ -399,7 +399,7 @@ class PaypalController extends Controller public function getTax($cartKey) { $m = new TeamStoreModel; - $updated_getSubtotal = $m->getSubtotal($cartKey); + $updated_getSubtotal = $m->getSubtotalNew($cartKey); $grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey); if (count($grouped_item) <= 0) { diff --git a/app/Models/teamstore/TeamStoreModel.php b/app/Models/teamstore/TeamStoreModel.php index 6073ac4..8cb17fa 100755 --- a/app/Models/teamstore/TeamStoreModel.php +++ b/app/Models/teamstore/TeamStoreModel.php @@ -189,6 +189,16 @@ class TeamStoreModel extends Model return $i; } + function getSubtotalNew($cartKey) + { + + $i = DB::table('cart_tmp')->select(DB::raw('SUM(Quantity * Price) AS Subtotal')) + ->where('CartKey', '=', $cartKey) + // ->where('VoucherId', '=', null) + ->get(); + return $i; + } + function updateStoreItem($data, $url) { $i = DB::table('teamstore_products')->where('ProductURL', $url) -- 2.49.1 From f197490606ae045f2b81198c6fc1b5d610cfcff3 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Wed, 27 Nov 2024 17:42:12 +0800 Subject: [PATCH 04/19] updated --- app/Http/Controllers/paypal/PaypalController.php | 6 ++++-- app/Http/Controllers/teamstore/TeamStoreController.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/paypal/PaypalController.php b/app/Http/Controllers/paypal/PaypalController.php index 61d1017..426f391 100755 --- a/app/Http/Controllers/paypal/PaypalController.php +++ b/app/Http/Controllers/paypal/PaypalController.php @@ -400,6 +400,7 @@ class PaypalController extends Controller { $m = new TeamStoreModel; $updated_getSubtotal = $m->getSubtotalNew($cartKey); + $original_subtotal = $m->getSubtotal($cartKey); // withoutTanle $grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey); if (count($grouped_item) <= 0) { @@ -414,10 +415,11 @@ class PaypalController extends Controller $order_grandtotal = $updated_getSubtotal[0]->Subtotal; + $order_subtotal = $original_subtotal[0]->Subtotal; + - - $tax = $order_grandtotal * $tax_value; + $tax = $order_subtotal * $tax_value; return [ 'tax' => $tax, diff --git a/app/Http/Controllers/teamstore/TeamStoreController.php b/app/Http/Controllers/teamstore/TeamStoreController.php index 1e479e9..f3b1ddc 100755 --- a/app/Http/Controllers/teamstore/TeamStoreController.php +++ b/app/Http/Controllers/teamstore/TeamStoreController.php @@ -978,6 +978,7 @@ class TeamStoreController extends Controller 'shippingFee' => number_format($shippingFee, 2), 'total' => number_format($finalSubTotal + $shippingFee + $tax["tax"], 2), 'subtotal' => number_format($finalSubTotal, 2), + 'tax' => $tax["tax"], 'remaining_shippingfee' => number_format(99 - $finalSubTotal, 2) )); } else { -- 2.49.1 From d6a98811eba6afda786f765d86c892eeee5c3e0d Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 13:30:00 +0800 Subject: [PATCH 05/19] Add CI/CD workflows for building and deploying Docker images --- .gitea/workflows/build-push.yml | 57 ++++++++++++ .gitea/workflows/deploy-dev.yml | 150 ++++++++++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 81 +++++++++++++++++ Dockerfile | 85 +++++++++++------- docker-compose.yml | 73 ++++++++-------- 5 files changed, 379 insertions(+), 67 deletions(-) create mode 100644 .gitea/workflows/build-push.yml create mode 100644 .gitea/workflows/deploy-dev.yml create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml new file mode 100644 index 0000000..3acd8f4 --- /dev/null +++ b/.gitea/workflows/build-push.yml @@ -0,0 +1,57 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: 'Docker image tag (e.g., v1.0.0, latest)' + required: false + default: 'latest' + push_to_registry: + description: 'Push to registry?' + required: false + default: 'true' + +jobs: + build-and-push: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.DOCKER_REGISTRY_URL }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ secrets.DOCKER_REGISTRY_URL }}/merchbay + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/merchbay:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/merchbay:buildcache,mode=max diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml new file mode 100644 index 0000000..2242bf7 --- /dev/null +++ b/.gitea/workflows/deploy-dev.yml @@ -0,0 +1,150 @@ +name: Deploy Development + +on: + push: + branches: + - dev + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + # 1๏ธโƒฃ Checkout code + - name: Checkout code + shell: sh + run: | + git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo + cd /workspace/repo + git checkout $GITHUB_REF_NAME + + # 2๏ธโƒฃ Build image + - name: Build Docker image + shell: sh + run: | + cd /workspace/repo + docker build -t merchbay:dev . + docker save merchbay:dev | gzip > merchbay_dev.tar.gz + + # 3๏ธโƒฃ Setup SSH + - name: Setup SSH + shell: sh + env: + DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts + + # 4๏ธโƒฃ Upload artifacts + - name: Upload image and compose + shell: sh + env: + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + run: | + scp -i ~/.ssh/id_ed25519 \ + /workspace/repo/merchbay_dev.tar.gz \ + /workspace/repo/docker-compose.yml \ + ${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/ + + # 5๏ธโƒฃ Deploy on server + - name: Deploy on server + shell: sh + env: + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + + run: | + ssh -i ~/.ssh/id_ed25519 $DEPLOY_USER@$DEPLOY_HOST << 'EOF' + set -e + + DEPLOY_DIR="/var/www/apps/merchbay_dev" + mkdir -p "$DEPLOY_DIR" + + echo "๐Ÿ“ฆ Loading image" + docker load < /tmp/merchbay_dev.tar.gz + + echo "๐Ÿ“„ Updating compose file" + cp /tmp/docker-compose.yml "$DEPLOY_DIR/" + + cd "$DEPLOY_DIR" + + echo "๐Ÿ” Checking .env file" + if [ ! -f .env ]; then + echo "โŒ .env file not found at $DEPLOY_DIR/.env" + echo "Please create it first with required variables:" + echo " - DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER" + exit 1 + fi + + echo "๐Ÿ”ง Fixing .env permissions" + sudo chown $USER:$USER .env + sudo chmod 600 .env + + echo "๐ŸŒ Ensure networks" + docker network inspect traefik-public >/dev/null 2>&1 || \ + docker network create traefik-public + docker network inspect crew-app-net >/dev/null 2>&1 || \ + docker network create crew-app-net + + echo "๐Ÿš€ Starting containers (env vars from .env file)" + docker compose up -d + + echo "โณ Waiting for app container" + sleep 15 + + if docker ps --format '{{.Names}}' | grep -q merchbay_app; then + echo "๐Ÿงน Clearing and rebuilding config cache" + docker compose exec -T app php artisan config:clear + docker compose exec -T app php artisan config:cache + else + echo "โŒ App container not running" + docker compose logs + exit 1 + fi + + echo "๐Ÿงน Cleanup" + rm -f /tmp/merchbay_dev.tar.gz /tmp/docker-compose.yml + docker image prune -f + + echo "โœ… Deployment completed" + EOF + + + # 6๏ธโƒฃ Health check + - name: Health check + shell: sh + run: | + echo "โณ Waiting for app to be ready..." + sleep 20 + + echo "๐Ÿ” Testing health check (ignoring SSL cert for now)..." + HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" --max-time 30 https://dev.merchbay.app || echo "000") + + if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "301" ]; then + echo "โœ… Health check passed! (HTTP $HTTP_CODE)" + echo "โš ๏ธ Note: Using -k to ignore SSL cert. Check Traefik logs if cert not ready." + else + echo "โŒ Health check failed! (HTTP $HTTP_CODE)" + echo "" + echo "๐Ÿ’ก Troubleshooting:" + echo " 1. Check if container is running:" + echo " docker ps | grep merchbay_app" + echo "" + echo " 2. Check app logs:" + echo " docker logs merchbay_app" + echo "" + echo " 3. Check Traefik logs:" + echo " docker logs traefik" + echo "" + echo " 4. Test manually:" + echo " curl -Ik https://dev.merchbay.app" + exit 1 + fi diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..859274b --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,81 @@ +name: Deploy Production + +on: + push: + branches: + - main + - master + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + - name: Checkout code + shell: sh + run: | + git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo || true + cd /workspace/repo + git fetch origin $GITHUB_REF_NAME + git checkout $GITHUB_REF_NAME + git pull origin $GITHUB_REF_NAME + + - name: Build Docker Image + shell: sh + run: | + cd /workspace/repo + docker build -t merchbay:latest . + docker save merchbay:latest | gzip > merchbay.tar.gz + + - name: Setup SSH and Deploy + shell: sh + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "$PROD_DEPLOY_SSH_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh-keygen -y -f ~/.ssh/deploy_key > /dev/null 2>&1 || { echo "Error: Invalid SSH key format"; exit 1; } + + cd /workspace/repo + scp -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key merchbay.tar.gz docker-compose.yml "$PROD_DEPLOY_USER@$PROD_DEPLOY_HOST:/tmp/" + + ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key "$PROD_DEPLOY_USER@$PROD_DEPLOY_HOST" " + DEPLOY_DIR='/var/www/merchbay' + mkdir -p \$DEPLOY_DIR + cd /tmp + docker load < merchbay.tar.gz + cp docker-compose.yml \$DEPLOY_DIR/ + cd \$DEPLOY_DIR + + # .env file should already exist on server with all required variables + # Required: DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER + # If it doesn't exist, deployment will fail (this is intentional for security) + + docker compose down || true + docker image prune -f + docker network inspect traefik-public >/dev/null 2>&1 || docker network create traefik-public + export DOMAIN=merchbay.app + export APP_URL=https://merchbay.app + docker compose up -d + sleep 10 + docker compose exec -T app php artisan migrate --force + docker compose exec -T app php artisan config:cache + docker compose exec -T app php artisan route:cache + docker compose exec -T app php artisan view:cache + rm -f /tmp/merchbay.tar.gz /tmp/docker-compose.yml + echo 'Production deployment completed successfully!' + echo 'Application available at: https://merchbay.app' + " + env: + PROD_DEPLOY_SSH_KEY: ${{ secrets.PROD_DEPLOY_SSH_KEY }} + PROD_DEPLOY_USER: ${{ secrets.PROD_DEPLOY_USER }} + PROD_DEPLOY_HOST: ${{ secrets.PROD_DEPLOY_HOST }} + + - name: Health Check + shell: sh + run: | + sleep 10 + curl -f https://merchbay.app || exit 1 diff --git a/Dockerfile b/Dockerfile index 8a08879..0fe21a9 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,71 @@ -# Use the official PHP image based on Alpine Linux -FROM php:5.6-fpm-alpine +# Use PHP 7.4 with Apache (compatible with Laravel 5.2 and ARM64) +FROM php:7.4-apache -# Install system dependencies and PHP extensions -RUN apk --update --no-cache add \ - nginx \ +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ libpng-dev \ - libjpeg-turbo-dev \ - freetype-dev \ + libonig-dev \ + libxml2-dev \ libzip-dev \ zip \ unzip \ - libmcrypt-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + openssh-client \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && docker-php-ext-install gd pdo pdo_mysql zip mcrypt + && docker-php-ext-install -j$(nproc) gd -# Set the working directory in the container -WORKDIR /var/www +# Install PHP extensions +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip -# Clear cache -# RUN apt-get clean && rm -rf /var/lib/apt/lists/* - -# Copy the Laravel application files to the container -COPY . . - -# Set appropriate permissions for Laravel storage and bootstrap cache -RUN chown -R www-data:www-data storage bootstrap +# Enable Apache mod_rewrite +RUN a2enmod rewrite # Install Composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer -# Install Laravel dependencies -RUN composer install --no-plugins --no-scripts +# Set working directory +WORKDIR /var/www/html -# Generate Laravel application key +# Copy existing application directory contents +COPY . /var/www/html + +# Create storage directories and set permissions +RUN mkdir -p storage/framework/views \ + storage/framework/cache \ + storage/framework/sessions \ + storage/logs \ + bootstrap/cache + +# Set proper ownership and permissions +RUN chown -R www-data:www-data /var/www/html \ + && chmod -R 775 /var/www/html/storage \ + && chmod -R 775 /var/www/html/bootstrap/cache + +# Create .env file if it doesn't exist +RUN if [ ! -f .env ]; then cp .env.example .env; fi + +# Install PHP dependencies without running post-install scripts +RUN composer install --no-dev --no-scripts --no-interaction + +# Generate application key RUN php artisan key:generate -# Create directory for the socket and set permissions -RUN mkdir -p /run/php && chown www-data:www-data /run/php +# Optimize autoloader +RUN composer dump-autoload --optimize --no-dev -# Copy the www.conf file to PHP-FPM pool.d directory -# COPY www.conf /usr/local/etc/php-fpm.d/www.conf +# Configure Apache DocumentRoot to point to Laravel's public directory +ENV APACHE_DOCUMENT_ROOT=/var/www/html/public +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf -# Expose port 9000 and start php-fpm server -EXPOSE 9000 -CMD ["php-fpm"] \ No newline at end of file +# Suppress Apache ServerName warning +RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf + +# Expose port 80 +EXPOSE 80 + +# Start Apache +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1107cbf..7f223f9 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,45 +1,44 @@ -version: '3' services: - - #PHP Service app: - build: - context: . - dockerfile: Dockerfile - image: digitalocean.com/php - container_name: app + image: merchbay:dev + container_name: merchbay_app restart: unless-stopped - tty: true environment: - SERVICE_NAME: app - SERVICE_TAGS: dev - working_dir: /var/www + - APP_ENV=${APP_ENV:-production} + - APP_DEBUG=${APP_DEBUG:-false} + - APP_URL=${APP_URL:-http://localhost} + - DB_CONNECTION=mysql + - DB_HOST=${DB_HOST} + - DB_PORT=${DB_PORT:-3306} + - DB_DATABASE=${DB_DATABASE} + - DB_USERNAME=${DB_USERNAME} + - DB_PASSWORD=${DB_PASSWORD} + - IMAGES_DIRECTORY=${IMAGES_DIRECTORY} + - PRODUCTION_PRIVATE_SERVER=${PRODUCTION_PRIVATE_SERVER} volumes: - - ./:/var/www - - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini + - ./storage:/var/www/html/storage + - ./public/uploads:/var/www/html/public/uploads + labels: + - "traefik.enable=true" + - "traefik.http.routers.merchbay-dev.rule=Host(`dev.merchbay.app`)" + - "traefik.http.routers.merchbay-dev.entrypoints=websecure" + - "traefik.http.routers.merchbay-dev.tls=true" + - "traefik.http.routers.merchbay-dev.tls.certresolver=le" + - "traefik.http.services.merchbay-dev.loadbalancer.server.port=80" + # HTTP to HTTPS redirect + - "traefik.http.routers.merchbay-dev-http.rule=Host(`dev.merchbay.app`)" + - "traefik.http.routers.merchbay-dev-http.entrypoints=web" + - "traefik.http.routers.merchbay-dev-http.middlewares=https-redirect" + - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https" networks: - - app-network + - traefik-public + - crew-app-net + - default - #Nginx Service - webserver: - image: nginx:alpine - container_name: webserver - restart: unless-stopped - tty: true - ports: - - "10003:80" - - "10443:443" - volumes: - - ./:/var/www - - ./nginx/conf.d/:/etc/nginx/conf.d/ - networks: - - app-network - -#Docker Networks networks: - app-network: - driver: bridge -#Volumes -volumes: - dbdata: - driver: local \ No newline at end of file + traefik-public: + external: true + crew-app-net: + external: true + default: + driver: bridge \ No newline at end of file -- 2.49.1 From 0052044d6a90ed12b1863b917f3883ca8f9a65d4 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 13:36:54 +0800 Subject: [PATCH 06/19] Update Dockerfile to use PHP 7.3 and improve compatibility with Laravel 5.0 --- Dockerfile | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0fe21a9..7fbdcc3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# Use PHP 7.4 with Apache (compatible with Laravel 5.2 and ARM64) -FROM php:7.4-apache +# Use PHP 7.3 with Apache (compatible with Laravel 5.0) +FROM php:7.3-apache # Install system dependencies RUN apt-get update && apt-get install -y \ @@ -14,16 +14,21 @@ RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ openssh-client \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd # Install PHP extensions -RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip tokenizer + +# Install mcrypt via PECL (required for Laravel 5.0) +RUN apt-get install -y libmcrypt-dev \ + && pecl install mcrypt-1.0.4 \ + && docker-php-ext-enable mcrypt # Enable Apache mod_rewrite RUN a2enmod rewrite -# Install Composer +# Install Composer (version 1.x for better compatibility with Laravel 5.0) COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer # Set working directory @@ -47,14 +52,14 @@ RUN chown -R www-data:www-data /var/www/html \ # Create .env file if it doesn't exist RUN if [ ! -f .env ]; then cp .env.example .env; fi -# Install PHP dependencies without running post-install scripts -RUN composer install --no-dev --no-scripts --no-interaction +# Install PHP dependencies (Laravel 5.0 compatible) +RUN composer install --no-dev --no-interaction --prefer-dist # Generate application key -RUN php artisan key:generate +RUN php artisan key:generate || true -# Optimize autoloader -RUN composer dump-autoload --optimize --no-dev +# Run Laravel 5.0 optimization +RUN php artisan clear-compiled && php artisan optimize # Configure Apache DocumentRoot to point to Laravel's public directory ENV APACHE_DOCUMENT_ROOT=/var/www/html/public -- 2.49.1 From cd4c7086bf5f1f97a74cfde5216dd24b73be1665 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 13:48:54 +0800 Subject: [PATCH 07/19] Update environment variables in deployment files for improved configuration --- .gitea/workflows/deploy-dev.yml | 3 ++- .gitea/workflows/deploy.yml | 3 ++- docker-compose.yml | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml index 2242bf7..c46d44d 100644 --- a/.gitea/workflows/deploy-dev.yml +++ b/.gitea/workflows/deploy-dev.yml @@ -80,7 +80,8 @@ jobs: if [ ! -f .env ]; then echo "โŒ .env file not found at $DEPLOY_DIR/.env" echo "Please create it first with required variables:" - echo " - DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER" + echo " - DB_*, PROD_PRIVATE, IMAGES_URL, UPLOAD_URL" + echo " - MAIL_*, CAPTCHA_*, ANALYTICS_*" exit 1 fi diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 859274b..1addd0e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -51,7 +51,8 @@ jobs: cd \$DEPLOY_DIR # .env file should already exist on server with all required variables - # Required: DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER + # Required: DB_*, PROD_PRIVATE, IMAGES_URL, UPLOAD_URL + # Required: MAIL_*, CAPTCHA_*, ANALYTICS_* # If it doesn't exist, deployment will fail (this is intentional for security) docker compose down || true diff --git a/docker-compose.yml b/docker-compose.yml index 7f223f9..31eef3d 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,20 @@ services: - DB_DATABASE=${DB_DATABASE} - DB_USERNAME=${DB_USERNAME} - DB_PASSWORD=${DB_PASSWORD} - - IMAGES_DIRECTORY=${IMAGES_DIRECTORY} - - PRODUCTION_PRIVATE_SERVER=${PRODUCTION_PRIVATE_SERVER} + - PROD_PRIVATE=${PROD_PRIVATE} + - IMAGES_URL=${IMAGES_URL} + - UPLOAD_URL=${UPLOAD_URL} + - MAIL_DRIVER=${MAIL_DRIVER} + - MAIL_HOST=${MAIL_HOST} + - MAIL_PORT=${MAIL_PORT} + - MAIL_USERNAME=${MAIL_USERNAME} + - MAIL_PASSWORD=${MAIL_PASSWORD} + - MAIL_ENCRYPTION=${MAIL_ENCRYPTION} + - CAPTCHA_SITE_KEY=${CAPTCHA_SITE_KEY} + - CAPTCHA_SECRET_KEY=${CAPTCHA_SECRET_KEY} + - ANALYTICS_SITE_ID=${ANALYTICS_SITE_ID} + - ANALYTICS_CLIENT_ID=${ANALYTICS_CLIENT_ID} + - ANALYTICS_SERVICE_EMAIL=${ANALYTICS_SERVICE_EMAIL} volumes: - ./storage:/var/www/html/storage - ./public/uploads:/var/www/html/public/uploads -- 2.49.1 From 564719412b944b09c4ccbbd97938b76dd85f16f8 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 13:58:13 +0800 Subject: [PATCH 08/19] Add entrypoint script to set up permissions and create storage directories --- Dockerfile | 7 ++++++- docker-entrypoint.sh | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 7fbdcc3..f913dfc 100755 --- a/Dockerfile +++ b/Dockerfile @@ -69,8 +69,13 @@ RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf # Suppress Apache ServerName warning RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf +# Copy entrypoint script +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + # Expose port 80 EXPOSE 80 -# Start Apache +# Use entrypoint to set up permissions before starting Apache +ENTRYPOINT ["docker-entrypoint.sh"] CMD ["apache2-foreground"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..7d70888 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +# Create storage directory structure if it doesn't exist +mkdir -p storage/framework/views +mkdir -p storage/framework/cache +mkdir -p storage/framework/sessions +mkdir -p storage/logs +mkdir -p storage/app/public +mkdir -p bootstrap/cache + +# Set proper permissions +chown -R www-data:www-data storage bootstrap/cache +chmod -R 775 storage bootstrap/cache + +# Execute the main command +exec "$@" -- 2.49.1 From c950a72fc82b1949d130e677787ae964c09a13dd Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:05:22 +0800 Subject: [PATCH 09/19] Update Dockerfile to revert to PHP 7.0 and adjust Debian repository sources --- Dockerfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index f913dfc..c8fc22d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ -# Use PHP 7.3 with Apache (compatible with Laravel 5.0) -FROM php:7.3-apache +# Use PHP 7.0 with Apache (has native mcrypt support for Laravel 5.0) +FROM php:7.0-apache + +# Update to use archived Debian repositories +RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \ + && sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list \ + && sed -i '/stretch-updates/d' /etc/apt/sources.list # Install system dependencies -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --allow-unauthenticated \ git \ curl \ libpng-dev \ - libonig-dev \ libxml2-dev \ - libzip-dev \ + libmcrypt-dev \ zip \ unzip \ libfreetype6-dev \ @@ -17,13 +21,8 @@ RUN apt-get update && apt-get install -y \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd -# Install PHP extensions -RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip tokenizer - -# Install mcrypt via PECL (required for Laravel 5.0) -RUN apt-get install -y libmcrypt-dev \ - && pecl install mcrypt-1.0.4 \ - && docker-php-ext-enable mcrypt +# Install PHP extensions (mcrypt is built-in for PHP 7.0) +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath mcrypt tokenizer zip # Enable Apache mod_rewrite RUN a2enmod rewrite -- 2.49.1 From 0a235a0ed201ed95c4f3182ddda85eff52587ace Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:07:01 +0800 Subject: [PATCH 10/19] Update README.md to enhance project documentation and clarify setup instructions --- readme.md | 176 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 162 insertions(+), 14 deletions(-) diff --git a/readme.md b/readme.md index a4d8d55..3ad835d 100755 --- a/readme.md +++ b/readme.md @@ -1,23 +1,171 @@ -## Laravel PHP Framework +# MerchBay -[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) -[![Total Downloads](https://poser.pugx.org/laravel/framework/downloads.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) -[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) +A custom merchandise and apparel design platform built with Laravel 5.0, enabling users to create, customize, and order personalized products. -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching. +## ๐Ÿš€ Tech Stack -Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. +- **Framework:** Laravel 5.0 +- **PHP:** 7.0 with native mcrypt support +- **Web Server:** Apache 2.4 +- **Database:** MySQL +- **Container:** Docker with Apache +- **Reverse Proxy:** Traefik (for SSL/TLS and routing) -## Official Documentation +## ๐Ÿ“‹ Prerequisites -Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs). +- Docker and Docker Compose +- Git +- Access to deployment server (for production/dev deployments) -## Contributing +## ๐Ÿ› ๏ธ Local Development -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). +### Building the Docker Image -### License +```bash +docker build -t merchbay:dev . +``` -The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) +### Running Locally + +```bash +# Create .env file from example +cp .env.example .env + +# Update .env with your local configuration +# Set database credentials, mail settings, etc. + +# Run with docker-compose (customize docker-compose.yml for local setup) +docker-compose up -d +``` + +### Environment Variables + +The following environment variables are required: + +#### Database Configuration +- `DB_HOST` - Database host +- `DB_PORT` - Database port (default: 3306) +- `DB_DATABASE` - Database name +- `DB_USERNAME` - Database username +- `DB_PASSWORD` - Database password + +#### Application URLs +- `APP_URL` - Application base URL +- `PROD_PRIVATE` - Production private server URL +- `IMAGES_URL` - Images server URL +- `UPLOAD_URL` - Upload directory URL + +#### Mail Configuration +- `MAIL_DRIVER` - Mail driver (smtp) +- `MAIL_HOST` - SMTP host +- `MAIL_PORT` - SMTP port +- `MAIL_USERNAME` - SMTP username +- `MAIL_PASSWORD` - SMTP password +- `MAIL_ENCRYPTION` - Encryption type (tls/ssl) + +#### Third-Party Services +- `CAPTCHA_SITE_KEY` - reCAPTCHA site key +- `CAPTCHA_SECRET_KEY` - reCAPTCHA secret key +- `ANALYTICS_SITE_ID` - Google Analytics site ID +- `ANALYTICS_CLIENT_ID` - Google Analytics client ID +- `ANALYTICS_SERVICE_EMAIL` - Google Analytics service email + +## ๐Ÿšข Deployment + +### Automated CI/CD with Gitea Actions + +This project includes automated deployment workflows using Gitea Actions: + +#### Development Deployment +Push to the `dev` branch to automatically deploy to dev environment: +```bash +git push origin dev +``` +- Deploys to: `https://dev.merchbay.app` + +#### Production Deployment +Push to the `main` or `master` branch to automatically deploy to production: +```bash +git push origin main +``` +- Deploys to: `https://merchbay.app` + +#### Docker Registry +Create version tags to build and push to Docker registry: +```bash +git tag -a v1.0.0 -m "Release v1.0.0" +git push origin v1.0.0 +``` + +### Workflow Files + +- `.gitea/workflows/deploy-dev.yml` - Development deployment +- `.gitea/workflows/deploy.yml` - Production deployment +- `.gitea/workflows/build-push.yml` - Docker image build and push + +## ๐Ÿ“ Project Structure + +``` +merchbay/ +โ”œโ”€โ”€ app/ # Application core +โ”‚ โ”œโ”€โ”€ Http/ # Controllers, middleware, routes +โ”‚ โ”œโ”€โ”€ Models/ # Database models +โ”‚ โ””โ”€โ”€ Services/ # Business logic services +โ”œโ”€โ”€ config/ # Configuration files +โ”œโ”€โ”€ database/ # Migrations and seeds +โ”œโ”€โ”€ public/ # Public assets (images, CSS, JS) +โ”œโ”€โ”€ resources/ # Views and frontend assets +โ”œโ”€โ”€ storage/ # Application storage +โ”œโ”€โ”€ docker-compose.yml # Docker compose configuration +โ”œโ”€โ”€ Dockerfile # Docker image definition +โ””โ”€โ”€ docker-entrypoint.sh # Container startup script +``` + +## ๐Ÿ”ง Development Notes + +### Storage Permissions + +The Docker entrypoint automatically creates and sets proper permissions for: +- `storage/framework/views` +- `storage/framework/cache` +- `storage/framework/sessions` +- `storage/logs` +- `bootstrap/cache` + +### PHP Extensions + +The following PHP extensions are installed: +- pdo_mysql +- mbstring +- exif +- pcntl +- bcmath +- mcrypt (native in PHP 7.0) +- tokenizer +- zip +- gd (with freetype and jpeg support) + +## ๐Ÿ› Troubleshooting + +### 500 Internal Server Error + +1. Check container logs: `docker logs merchbay_app` +2. Verify storage permissions are set correctly +3. Ensure all environment variables are configured in `.env` +4. Check database connectivity + +### Storage Permission Issues + +The entrypoint script automatically fixes permissions on container start. If issues persist: +```bash +docker exec merchbay_app chown -R www-data:www-data storage bootstrap/cache +docker exec merchbay_app chmod -R 775 storage bootstrap/cache +``` + +## ๐Ÿ“„ License + +Proprietary - All rights reserved + +## ๐Ÿค Support + +For support and questions, contact the development team. -- 2.49.1 From 807ac03d0367bc7ed3cc1182fc46acffacefdc98 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:18:28 +0800 Subject: [PATCH 11/19] Refactor asset paths in Blade templates to remove 'public' prefix for improved consistency --- resources/views/merchbay_main.blade.php | 12 ++-- .../user-layouts/user_template.blade.php | 56 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/resources/views/merchbay_main.blade.php b/resources/views/merchbay_main.blade.php index 35a1104..2876577 100755 --- a/resources/views/merchbay_main.blade.php +++ b/resources/views/merchbay_main.blade.php @@ -10,13 +10,13 @@ Merchbay - + - - + + @@ -258,7 +258,7 @@ } function fetchCanada() { - $.getJSON("{{ asset('/public/api/canada.json') }}", function(items) { + $.getJSON("{{ asset('//api/canada.json') }}", function(items) { var states = []; Object.keys(items).forEach(function(state) { @@ -307,7 +307,7 @@ } function fetchUSA() { - $.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) { + $.getJSON("{{ asset('//api/usaCities.json') }}", function(data) { var states = []; for (i = 0; i < data.length; i++) { diff --git a/resources/views/user-layouts/user_template.blade.php b/resources/views/user-layouts/user_template.blade.php index 1355511..a723cda 100755 --- a/resources/views/user-layouts/user_template.blade.php +++ b/resources/views/user-layouts/user_template.blade.php @@ -13,37 +13,37 @@ - + - + - + - + - + - + - + - + - + - + - - + + @@ -628,41 +628,41 @@ - + - + - + - + - + - + - + - + - + - + - - + + @@ -671,9 +671,9 @@ - + - + {{-- Chartjs --}} @@ -1791,7 +1791,7 @@ } function fetchCanada() { - $.getJSON("{{ asset('/public/api/canada.json') }}", function(items) { + $.getJSON("{{ asset('/api/canada.json') }}", function(items) { var states = []; Object.keys(items).forEach(function(state) { @@ -1840,7 +1840,7 @@ } function fetchUSA() { - $.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) { + $.getJSON("{{ asset('/api/usaCities.json') }}", function(data) { var states = []; for (i = 0; i < data.length; i++) { -- 2.49.1 From e6ffc878ddef2f2ac29ff62e026520deca4a4cf9 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:22:09 +0800 Subject: [PATCH 12/19] Add HTTPS schema enforcement in AppServiceProvider and set FORCE_HTTPS in Docker Compose --- app/Providers/AppServiceProvider.php | 6 +++++- docker-compose.yml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 9d036bb..9e53a91 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -15,7 +15,11 @@ class AppServiceProvider extends ServiceProvider { */ public function boot() { - // + // Force HTTPS URLs when behind a proxy (Traefik) + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + \URL::forceSchema('https'); + } + Blade::extend(function($value) { return preg_replace('/\@define(.+)/', '', $value); }); diff --git a/docker-compose.yml b/docker-compose.yml index 31eef3d..951c536 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - PROD_PRIVATE=${PROD_PRIVATE} - IMAGES_URL=${IMAGES_URL} - UPLOAD_URL=${UPLOAD_URL} + - FORCE_HTTPS=true - MAIL_DRIVER=${MAIL_DRIVER} - MAIL_HOST=${MAIL_HOST} - MAIL_PORT=${MAIL_PORT} -- 2.49.1 From 89201a843200c2f40afadcdd14dde4ec25e62322 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:24:24 +0800 Subject: [PATCH 13/19] Add yakpro-po for code obfuscation and configuration for Laravel 5.0 --- Dockerfile | 15 ++++++++++++++ yakpro-po.cnf | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 yakpro-po.cnf diff --git a/Dockerfile b/Dockerfile index c8fc22d..912bc83 100755 --- a/Dockerfile +++ b/Dockerfile @@ -57,6 +57,21 @@ RUN composer install --no-dev --no-interaction --prefer-dist # Generate application key RUN php artisan key:generate || true +# Install yakpro-po for code obfuscation +RUN cd /tmp && \ + git clone https://github.com/pk-fr/yakpro-po.git && \ + cd yakpro-po && \ + chmod +x yakpro-po.php + +# Obfuscate application code (app directory only, preserve vendor) +RUN php /tmp/yakpro-po/yakpro-po.php \ + --config-file /var/www/html/yakpro-po.cnf \ + /var/www/html/app \ + -o /var/www/html/app_obfuscated && \ + rm -rf /var/www/html/app && \ + mv /var/www/html/app_obfuscated /var/www/html/app && \ + rm -rf /tmp/yakpro-po + # Run Laravel 5.0 optimization RUN php artisan clear-compiled && php artisan optimize diff --git a/yakpro-po.cnf b/yakpro-po.cnf new file mode 100644 index 0000000..ccd7c1c --- /dev/null +++ b/yakpro-po.cnf @@ -0,0 +1,54 @@ +t_directories = [ + 'app' +]; + +// Directories/files to skip +$conf->t_skip = [ + 'vendor', + 'storage', + 'bootstrap', + 'config', + 'database', + 'public', + 'resources', + 'tests', + '.env', + '.env.example', + 'artisan', + 'server.php' +]; + +// Obfuscation options +$conf->obfuscate_string_literal = false; // Don't obfuscate strings (can break Laravel) +$conf->obfuscate_function_name = true; // Obfuscate function names +$conf->obfuscate_class_name = true; // Obfuscate class names (except Laravel core) +$conf->obfuscate_variable_name = true; // Obfuscate variable names +$conf->obfuscate_property_name = true; // Obfuscate property names +$conf->obfuscate_class_constant_name = true; +$conf->obfuscate_constant_name = true; +$conf->obfuscate_namespace_name = false; // Keep namespaces readable +$conf->obfuscate_label_name = true; + +// Keep Laravel framework methods/classes readable +$conf->t_ignore_constants = ['APP_ENV', 'APP_DEBUG', 'APP_URL', 'APP_KEY']; +$conf->t_ignore_methods = [ + '__construct', '__destruct', '__call', '__get', '__set', + 'boot', 'register', 'handle', 'middleware', 'authorize' +]; + +// Scrambler mode +$conf->scrambler = true; + +// Allow multiple PHP versions +$conf->allow_and_operator = true; + +// Output directory (will be overridden in command) +$conf->t_dir = null; + +return $conf; -- 2.49.1 From 14449ec0c110ed2cea49ac14f7f557c47722a9f7 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:32:59 +0800 Subject: [PATCH 14/19] Remove yakpro-po obfuscation steps from Dockerfile due to PHP 7.0 compatibility issues --- Dockerfile | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 912bc83..25ed8b4 100755 --- a/Dockerfile +++ b/Dockerfile @@ -57,24 +57,15 @@ RUN composer install --no-dev --no-interaction --prefer-dist # Generate application key RUN php artisan key:generate || true -# Install yakpro-po for code obfuscation -RUN cd /tmp && \ - git clone https://github.com/pk-fr/yakpro-po.git && \ - cd yakpro-po && \ - chmod +x yakpro-po.php - -# Obfuscate application code (app directory only, preserve vendor) -RUN php /tmp/yakpro-po/yakpro-po.php \ - --config-file /var/www/html/yakpro-po.cnf \ - /var/www/html/app \ - -o /var/www/html/app_obfuscated && \ - rm -rf /var/www/html/app && \ - mv /var/www/html/app_obfuscated /var/www/html/app && \ - rm -rf /tmp/yakpro-po - # Run Laravel 5.0 optimization RUN php artisan clear-compiled && php artisan optimize +# Note: yakpro-po obfuscation requires PHP 7.1+, incompatible with PHP 7.0 +# For code protection with PHP 7.0, consider: +# 1. ionCube Encoder (commercial, most secure) +# 2. Keeping source code private and using proper access controls +# 3. Using --optimize flag in composer (already done above) + # Configure Apache DocumentRoot to point to Laravel's public directory ENV APACHE_DOCUMENT_ROOT=/var/www/html/public RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf -- 2.49.1 From 1d4b33ef9fb04c6711784c75925b98cae5877cdb Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 14:51:20 +0800 Subject: [PATCH 15/19] Enhance deployment scripts by removing old Docker images and pruning unused resources --- .gitea/workflows/deploy-dev.yml | 9 ++++++++- .gitea/workflows/deploy.yml | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml index c46d44d..b383951 100644 --- a/.gitea/workflows/deploy-dev.yml +++ b/.gitea/workflows/deploy-dev.yml @@ -71,6 +71,9 @@ jobs: echo "๐Ÿ“ฆ Loading image" docker load < /tmp/merchbay_dev.tar.gz + echo "๐Ÿงน Removing old merchbay images" + docker images | grep merchbay | grep -v "$(docker images merchbay:dev -q)" | awk '{print $3}' | xargs -r docker rmi -f || true + echo "๐Ÿ“„ Updating compose file" cp /tmp/docker-compose.yml "$DEPLOY_DIR/" @@ -113,7 +116,11 @@ jobs: echo "๐Ÿงน Cleanup" rm -f /tmp/merchbay_dev.tar.gz /tmp/docker-compose.yml - docker image prune -f + + echo "๐Ÿงน Pruning unused Docker resources" + docker image prune -af --filter "until=24h" || true + docker container prune -f || true + docker system df echo "โœ… Deployment completed" EOF diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 1addd0e..0058f9a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -47,6 +47,10 @@ jobs: mkdir -p \$DEPLOY_DIR cd /tmp docker load < merchbay.tar.gz + + echo 'Removing old merchbay images' + docker images | grep merchbay | grep -v "\$(docker images merchbay:latest -q)" | awk '{print \$3}' | xargs -r docker rmi -f || true + cp docker-compose.yml \$DEPLOY_DIR/ cd \$DEPLOY_DIR @@ -67,6 +71,12 @@ jobs: docker compose exec -T app php artisan route:cache docker compose exec -T app php artisan view:cache rm -f /tmp/merchbay.tar.gz /tmp/docker-compose.yml + + echo 'Pruning unused Docker resources' + docker image prune -af --filter "until=24h" || true + docker container prune -f || true + docker system df + echo 'Production deployment completed successfully!' echo 'Application available at: https://merchbay.app' " -- 2.49.1 From 609d0144599a4013a7a273779f7a148ef5113009 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 15:03:49 +0800 Subject: [PATCH 16/19] Enhance Docker cleanup in deployment workflows to reclaim space --- .gitea/workflows/deploy-dev.yml | 5 ++++- .gitea/workflows/deploy.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml index b383951..499c4ba 100644 --- a/.gitea/workflows/deploy-dev.yml +++ b/.gitea/workflows/deploy-dev.yml @@ -117,9 +117,12 @@ jobs: echo "๐Ÿงน Cleanup" rm -f /tmp/merchbay_dev.tar.gz /tmp/docker-compose.yml - echo "๐Ÿงน Pruning unused Docker resources" + echo "๐Ÿงน Aggressive Docker cleanup to reclaim space" docker image prune -af --filter "until=24h" || true docker container prune -f || true + docker volume prune -f || true + docker builder prune -af --filter "until=48h" || true + echo "๐Ÿ“Š Docker space usage:" docker system df echo "โœ… Deployment completed" diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 0058f9a..aa31187 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -72,9 +72,12 @@ jobs: docker compose exec -T app php artisan view:cache rm -f /tmp/merchbay.tar.gz /tmp/docker-compose.yml - echo 'Pruning unused Docker resources' + echo 'Aggressive Docker cleanup to reclaim space' docker image prune -af --filter "until=24h" || true docker container prune -f || true + docker volume prune -f || true + docker builder prune -af --filter "until=48h" || true + echo 'Docker space usage:' docker system df echo 'Production deployment completed successfully!' -- 2.49.1 From 03434cede5189f15f70294af811a570f1960691e Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 15:22:24 +0800 Subject: [PATCH 17/19] Fix potential undefined index notices in UserController by adding isset checks for store data --- app/Http/Controllers/user/UserController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/user/UserController.php b/app/Http/Controllers/user/UserController.php index 4eda98a..c18fa7e 100755 --- a/app/Http/Controllers/user/UserController.php +++ b/app/Http/Controllers/user/UserController.php @@ -34,10 +34,10 @@ class UserController extends Controller $post_data = array( 'isStoreOwner' => true, - 'store_order' => $countStoreOrder[0]->count_order, - 'store_income' => $storeIncome[0]->store_income, - 'store_product_count' => $countStoreProduct[0]->store_product_count, - 'store_published_product' => $countStorePublishedProduct[0]->store_published_product + 'store_order' => isset($countStoreOrder[0]->count_order) ? $countStoreOrder[0]->count_order : 0, + 'store_income' => isset($storeIncome[0]->store_income) ? $storeIncome[0]->store_income : 0, + 'store_product_count' => isset($countStoreProduct[0]->store_product_count) ? $countStoreProduct[0]->store_product_count : 0, + 'store_published_product' => isset($countStorePublishedProduct[0]->store_published_product) ? $countStorePublishedProduct[0]->store_published_product : 0 ); } else { $post_data = array( -- 2.49.1 From e8d21d22f8ca5e79eae49ba37f520b3d52325844 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 16:30:14 +0800 Subject: [PATCH 18/19] Add local environment configuration and setup documentation for development --- .env.local | 36 +++++ LOCAL_DEVELOPMENT.md | 133 +++++++++++++++++++ docker-compose.local.yml | 81 +++++++++++ resources/views/user-layouts/index.blade.php | 48 ------- 4 files changed, 250 insertions(+), 48 deletions(-) create mode 100644 .env.local create mode 100644 LOCAL_DEVELOPMENT.md create mode 100644 docker-compose.local.yml diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..ef7599d --- /dev/null +++ b/.env.local @@ -0,0 +1,36 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=base64:YOUR_APP_KEY_HERE + +DB_HOST=db +DB_DATABASE=merchbay +DB_USERNAME=merchbay +DB_PASSWORD=secret +DB_PORT=3306 + +CACHE_DRIVER=file +SESSION_DRIVER=file +QUEUE_DRIVER=sync + +# Local mail (logs to storage/logs/laravel.log) +MAIL_DRIVER=log +MAIL_HOST=localhost +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null + +# Local URLs +APP_URL=http://localhost:8080 +PROD_PRIVATE=http://localhost:8080 +IMAGES_URL=http://localhost:8080 +UPLOAD_URL=http://localhost:8080/uploads/ + +# Test Captcha (for local dev) +CAPTCHA_SITE_KEY=test_key +CAPTCHA_SECRET_KEY=test_secret + +# Analytics (optional for local) +ANALYTICS_SITE_ID= +ANALYTICS_CLIENT_ID= +ANALYTICS_SERVICE_EMAIL= diff --git a/LOCAL_DEVELOPMENT.md b/LOCAL_DEVELOPMENT.md new file mode 100644 index 0000000..7f350d7 --- /dev/null +++ b/LOCAL_DEVELOPMENT.md @@ -0,0 +1,133 @@ +# Local Development Setup for Merchbay + +## Quick Start + +1. **Copy local environment file:** + ```bash + cp .env.local .env + ``` + +2. **Build and start containers:** + ```bash + docker-compose -f docker-compose.local.yml up -d --build + ``` + +3. **Generate application key:** + ```bash + docker exec merchbay_app_local php artisan key:generate + ``` + +4. **Run migrations:** + ```bash + docker exec merchbay_app_local php artisan migrate + ``` + +5. **Access the application:** + - **App:** http://localhost:8080 + - **phpMyAdmin:** http://localhost:8081 + - Username: `merchbay` + - Password: `secret` + +## Development Commands + +### View logs +```bash +# Application logs +docker exec merchbay_app_local tail -f storage/logs/laravel.log + +# Apache logs +docker logs -f merchbay_app_local +``` + +### Run artisan commands +```bash +docker exec merchbay_app_local php artisan [command] +``` + +### Access container shell +```bash +docker exec -it merchbay_app_local bash +``` + +### Database access +```bash +docker exec -it merchbay_db_local mysql -u merchbay -psecret merchbay +``` + +### Clear caches +```bash +docker exec merchbay_app_local php artisan cache:clear +docker exec merchbay_app_local php artisan config:clear +docker exec merchbay_app_local php artisan view:clear +``` + +### Stop containers +```bash +docker-compose -f docker-compose.local.yml down +``` + +### Stop and remove volumes (clean slate) +```bash +docker-compose -f docker-compose.local.yml down -v +``` + +## Debugging + +### Enable Xdebug (if needed) +Add to Dockerfile: +```dockerfile +RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug +``` + +### Check container status +```bash +docker-compose -f docker-compose.local.yml ps +``` + +### View all logs +```bash +docker-compose -f docker-compose.local.yml logs -f +``` + +## Hot Reload Development + +For live code changes without rebuilding: +- Code changes in `.php` files are reflected immediately (via volume mount) +- View changes are reflected immediately +- Config/route changes require cache clearing + +## Database Management + +### Import SQL dump +```bash +docker exec -i merchbay_db_local mysql -u merchbay -psecret merchbay < dump.sql +``` + +### Export database +```bash +docker exec merchbay_db_local mysqldump -u merchbay -psecret merchbay > dump.sql +``` + +## Troubleshooting + +### Permission issues +```bash +docker exec merchbay_app_local chown -R www-data:www-data storage bootstrap/cache +docker exec merchbay_app_local chmod -R 775 storage bootstrap/cache +``` + +### Reset everything +```bash +docker-compose -f docker-compose.local.yml down -v +docker rmi merchbay_app:local +rm .env +cp .env.local .env +docker-compose -f docker-compose.local.yml up -d --build +``` + +## Notes + +- The local setup uses a separate MySQL container +- All code changes are live-mounted for easy development +- Mail is logged to `storage/logs/laravel.log` instead of being sent +- phpMyAdmin is available for easy database management diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..f49a4be --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,81 @@ +services: + db: + image: mariadb:10.6 + platform: linux/arm64 + container_name: merchbay_db_local + restart: unless-stopped + environment: + MYSQL_DATABASE: merchbay + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: merchbay + MYSQL_PASSWORD: secret + ports: + - "3306:3306" + volumes: + - db_data:/var/lib/mysql + networks: + - merchbay-local + + app: + build: + context: . + dockerfile: Dockerfile + container_name: merchbay_app_local + restart: unless-stopped + ports: + - "8080:80" + environment: + - APP_ENV=local + - APP_DEBUG=true + - APP_URL=http://localhost:8080 + - DB_CONNECTION=mysql + - DB_HOST=db + - DB_PORT=3306 + - DB_DATABASE=merchbay + - DB_USERNAME=merchbay + - DB_PASSWORD=secret + - PROD_PRIVATE=http://localhost:8080 + - IMAGES_URL=http://localhost:8080 + - UPLOAD_URL=http://localhost:8080/uploads/ + - MAIL_DRIVER=log + - MAIL_HOST=localhost + - MAIL_PORT=1025 + - MAIL_USERNAME=null + - MAIL_PASSWORD=null + - MAIL_ENCRYPTION=null + - CAPTCHA_SITE_KEY=test_key + - CAPTCHA_SECRET_KEY=test_secret + - ANALYTICS_SITE_ID= + - ANALYTICS_CLIENT_ID= + - ANALYTICS_SERVICE_EMAIL= + volumes: + - ./:/var/www/html + - ./storage:/var/www/html/storage + - ./public/uploads:/var/www/html/public/uploads + depends_on: + - db + networks: + - merchbay-local + + phpmyadmin: + image: arm64v8/phpmyadmin + platform: linux/arm64 + container_name: merchbay_phpmyadmin + restart: unless-stopped + ports: + - "8081:80" + environment: + PMA_HOST: db + PMA_PORT: 3306 + MYSQL_ROOT_PASSWORD: root + depends_on: + - db + networks: + - merchbay-local + +networks: + merchbay-local: + driver: bridge + +volumes: + db_data: diff --git a/resources/views/user-layouts/index.blade.php b/resources/views/user-layouts/index.blade.php index 6e4057f..f67e559 100755 --- a/resources/views/user-layouts/index.blade.php +++ b/resources/views/user-layouts/index.blade.php @@ -86,54 +86,6 @@ - {{--
-
-
-
-

Total Sales

-
- - -
-
-
-
-
- - -
-
- - -
-
-
-
- -
-
- -
-
-
--}} @else