Skip to content

Commit

Permalink
build: DOMPFD was installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josemprog committed Nov 18, 2020
1 parent 34df210 commit 38113a3
Show file tree
Hide file tree
Showing 16 changed files with 606 additions and 393 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.vscode
19 changes: 9 additions & 10 deletions app/Http/Controllers/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public function store(ProductsRequest $request): \Illuminate\Http\RedirectRespon
$product = new Product($request->validated());
$product->image = $request->file('image')->store('images', 'public');
$product->save();

// Optimizing the image

$image = Image::make(storage_path('app/public/' . $product->image));
$image->widen(600)->limitColors(255, '#ff9900')->encode();
Storage::put($product->image, (string) $image);
Expand Down Expand Up @@ -114,23 +113,19 @@ public function edit(Product $product): \Illuminate\View\View
*/
public function update(Product $product, ProductsRequest $request): \Illuminate\Http\RedirectResponse
{


if ($request->hasFile('image')) {


Storage::disk('public')->delete($product->image);
Storage::delete($product->image);

$product->fill($request->validated());
$product->image = $request->file('image')->store('images', 'public');
$product->save();

$image = Image::make(storage_path('app/public/' . $product->image));
$image->widen(600)->limitColors(255, '#ff9900')->encode();

Storage::put($product->image, (string) $image);
} else {

$product->update($request->validated());
}

Expand All @@ -147,7 +142,6 @@ public function update(Product $product, ProductsRequest $request): \Illuminate\
*/
public function destroy(Product $product): \Illuminate\Http\RedirectResponse
{

Storage::disk('public')->delete($product->image);
Storage::delete($product->image);

Expand All @@ -158,7 +152,12 @@ public function destroy(Product $product): \Illuminate\Http\RedirectResponse
->with('message', 'Product Removed');
}

public function export()
/**
* Export all products
*
* @return \Illuminate\Http\RedirectResponse
*/
public function export():\Illuminate\Http\RedirectResponse
{
(new ProductsExport())->store('products.csv');
return back()->with('message', 'Export started!');
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function edit(User $user): \Illuminate\View\View
*/
public function update(User $user, SaveUsers $request): \Illuminate\Http\RedirectResponse
{

$user->update($request->validated());

return redirect()
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class CartController extends Controller
{

public $cartService;

public function __construct(CartService $cartService)
Expand Down
36 changes: 18 additions & 18 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(): \Illuminate\View\View
{
return view('home');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(): \Illuminate\View\View
{
return view('home');
}
}
7 changes: 0 additions & 7 deletions app/Http/Controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class OrderController extends Controller
{

public $cartService;
public $p2p;

Expand Down Expand Up @@ -61,14 +60,11 @@ public function create(): \Illuminate\View\View
*/
public function show(Order $order): \Illuminate\View\View
{

$payment = $this->p2p->getInformation($order->requestId);

if ($order->status == 'PENDING') {

$order->status = $payment['status']['status'];
$order->save();

}


Expand All @@ -94,8 +90,6 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
->back()
->withErrors("Your cart is empty");
} else {


$user = $request->user();

if (!isset($order) || $user->orders->isEmpty()) {
Expand Down Expand Up @@ -135,7 +129,6 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
*/
public function retry(Request $request, Order $order): \Illuminate\Http\RedirectResponse
{

$payment = $this->p2p->createRequest($order, $request);

$order->processUrl = $payment['processUrl'];
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/ProductCartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ public function removeOne(Product $product, Cart $cart): \Illuminate\Http\Redire
->quantity ?? 0;

if ($quantity <= 1) {

$cart->products()->detach($product->id);

return redirect()->back();
} else {

$cart->products()->syncWithoutDetaching([
$product->id => ['quantity' => $quantity - 1],
]);
Expand Down
72 changes: 36 additions & 36 deletions app/Services/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@

class CartService
{
/**
* returns the user's first cart
*
* @return void
*/
public function getCartFromUser()
{
return Auth::user()->cart()->first();
}


/**
* The user's cart is selected or a new cart is created for the user
*
* @return void
*/
public function getFromUserOrCreate()
{
$cart = $this->getCartFromUser();

return $cart ?? Auth::user()->cart()->create();
}

/**
* the products in the cart are counted
*
* @return void
*/
public function countProductsInCart()
{
$cart = $this->getCartFromUser();

if ($cart != null) {
return $cart->products->pluck('pivot.quantity')->sum();
/**
* returns the user's first cart
*
* @return void
*/
public function getCartFromUser()
{
return Auth::user()->cart()->first();
}


/**
* The user's cart is selected or a new cart is created for the user
*
* @return void
*/
public function getFromUserOrCreate()
{
$cart = $this->getCartFromUser();

return $cart ?? Auth::user()->cart()->create();
}

/**
* the products in the cart are counted
*
* @return void
*/
public function countProductsInCart()
{
$cart = $this->getCartFromUser();

if ($cart != null) {
return $cart->products->pluck('pivot.quantity')->sum();
}
return 0;
}
return 0;
}
}
Loading

0 comments on commit 38113a3

Please sign in to comment.