Skip to content

Commit

Permalink
Code commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Slymee committed Mar 28, 2024
1 parent b04bd6e commit a505871
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/Repositories/AdminCategoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@

class AdminCategoryRepository implements AdminCategoryRepositoryInterface
{
/**
* Get all Parent category
* @return mixed
*/
public function getAll()
{
return Category::whereNull('parent_id')->paginate(10);
}

/**
* Get existing category for new category
* @return mixed
*/
public function create()
{
$data = Category::whereNull('parent_id')
Expand All @@ -24,6 +32,12 @@ public function create()
return $data;
}

/**
* Store new category
* @param array $data
* @return array
* @throws \Exception
*/
public function store(array $data)
{
try {
Expand All @@ -44,6 +58,11 @@ public function store(array $data)
}
}

/**
* Get existing data to edit
* @param string $categoryId
* @return array
*/
public function edit(string $categoryId): array
{
$editableData = Category::select('id', 'category_name', 'parent_id')->findOrFail($categoryId);
Expand All @@ -54,6 +73,11 @@ public function edit(string $categoryId): array
return ['editableData' => $editableData, 'datas' => $data];
}

/**
* Update the existing category
* @param array $data
* @return \Illuminate\Http\RedirectResponse
*/
public function update(array $data): \Illuminate\Http\RedirectResponse
{
try {
Expand All @@ -77,11 +101,22 @@ public function update(array $data): \Illuminate\Http\RedirectResponse
}
}

/**
* Delete category
* @param string $categoryId
* @return void
*/
public function destroy(string $categoryId)
{
Category::find($categoryId)->delete();
}

/**
* get paginated category
* @param string $term
* @return \Illuminate\Http\JsonResponse
*
*/
public function getPaginatedCategory(string $term): \Illuminate\Http\JsonResponse
{
$mainParent = Category::where('category_name', 'like', '%' . $term . '%')
Expand All @@ -91,6 +126,12 @@ public function getPaginatedCategory(string $term): \Illuminate\Http\JsonRespons
return response()->json(['items' => $mainParent->items()]);
}

/**
* Category Search module
* @param string $parentId
* @param string $term
* @return array
*/
public function displayChildCategory(string $parentId, string $term): array
{
$data = Category::where('category_name', 'like', '%' . $term . '%')
Expand Down
8 changes: 8 additions & 0 deletions app/Repositories/CartRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class CartRepository implements CartRepositoryInterface
{
/**
* Display cart items
* @param string $userId
* @return mixed
*/
Expand All @@ -26,6 +27,7 @@ public function showCartItems(string $userId)
}

/**
* Store cart items
* @param array $data
* @return bool
*/
Expand Down Expand Up @@ -62,6 +64,11 @@ public function store(array $data): bool
}


/**
* Update cart quantity
* @param array $data
* @return bool
*/
public function updateQuantity(array $data): bool
{
try {
Expand All @@ -82,6 +89,7 @@ public function updateQuantity(array $data): bool
}

/**
* Remove items from cart
* @param string $cartId
* @return bool
*/
Expand Down
5 changes: 5 additions & 0 deletions app/Repositories/CheckoutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

class CheckoutRepository implements CheckoutRepositoryInterface
{
/**
* Find product to checkout
* @param string $productId
* @return mixed
*/
public function getCheckoutProducts(string $productId)
{
return Product::find($productId);
Expand Down
2 changes: 2 additions & 0 deletions app/Repositories/CommentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class CommentRepository implements CommentRepositoryInterface
{
/**
* Fetch all comment
* @return Collection
*/
public function all(): Collection
Expand All @@ -19,6 +20,7 @@ public function all(): Collection
}

/**
* Stoe new comment/reply
* @param $data
* @return mixed
*/
Expand Down
11 changes: 11 additions & 0 deletions app/Repositories/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

class OrderRepository implements OrderRepositoryInterface
{
/**
* Store new order
* @param array $data
* @return bool
*/
public function storeOrder(array $data): bool
{
try {
Expand Down Expand Up @@ -42,6 +47,12 @@ public function storeOrder(array $data): bool
}
}

/**
* Send email receipt to customer
* @param $userDetails
* @param array $orderInfo
* @return void
*/
public function sendEmailReceipt($userDetails, array $orderInfo)
{
$nameOfUser = $userDetails->name;
Expand Down
19 changes: 19 additions & 0 deletions app/Repositories/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

class ProductRepository implements ProductRepositoryInterface
{
/**
* FInd particular product
* @param string $productId
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
* @throws \Exception
*/
public function show(string $productId): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
{
try {
Expand All @@ -21,6 +27,13 @@ public function show(string $productId): \Illuminate\Database\Eloquent\Model|\Il
}
}


/**
* Fetch product of particular category
* @param string $categoryId
* @return array
* @throws \Exception
*/
public function categoryProductList(string $categoryId): array
{
try {
Expand All @@ -47,6 +60,12 @@ public function categoryProductList(string $categoryId): array
}
}


/**
* fetch all child category
* @param $parentId
* @return array
*/
public function getAllChildrenCategory($parentId)
{
$childrenIds = Category::where('parent_id', $parentId)->pluck('id')->toArray();
Expand Down
24 changes: 24 additions & 0 deletions app/Repositories/SellerProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Illuminate\Support\Facades\Storage;
class SellerProductRepository implements SellerProductRepositoryInterface
{
/**
* Fetch all self product
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getAll(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
{
$user = auth()->user();
Expand All @@ -24,6 +28,12 @@ public function getById($id){
}


/**
* Store new product to sell
* @param array $data
* @return array|string[]
* @throws \Exception
*/
public function store(array $data): array
{
try {
Expand Down Expand Up @@ -61,6 +71,14 @@ public function store(array $data): array
throw $e;
}
}

/**
* update existing product
* @param $productId
* @param array $data
* @return array|string[]
* @throws \Exception
*/
public function update($productId, array $data): array
{
try {
Expand Down Expand Up @@ -105,6 +123,12 @@ public function update($productId, array $data): array
}
}

/**
* Remove existing product
* @param $productId
* @return array
* @throws \Exception
*/
public function delete($productId): array
{
try {
Expand Down
6 changes: 6 additions & 0 deletions app/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

class UserRepository implements UserRepositoryInterface
{

/**
* Create new user module
* @param array $data
* @return \Illuminate\Http\RedirectResponse
*/
public function createUser(array $data): \Illuminate\Http\RedirectResponse
{
try {
Expand Down

0 comments on commit a505871

Please sign in to comment.