-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from KalimeroMK/feature/API
Feature/api
- Loading branch information
Showing
241 changed files
with
4,113 additions
and
941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Modules\Banner\Http\Resource; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
use Modules\Banner\Models\Banner; | ||
|
||
/** @mixin Banner */ | ||
class BannerResource extends JsonResource | ||
{ | ||
/** | ||
* @param Request $request | ||
* | ||
* @return array | ||
*/ | ||
public function toArray($request): array | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'title' => $this->title, | ||
'slug' => $this->slug, | ||
'photo' => $this->photo, | ||
'description' => $this->description, | ||
'status' => $this->status, | ||
'created_at' => $this->created_at, | ||
'updated_at' => $this->updated_at, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Modules/Billing/Http/Controllers/Api/WishlistController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Modules\Billing\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Exception; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
use Modules\Billing\Http\Requests\Api\Store; | ||
use Modules\Billing\Http\Resources\WishlistResource; | ||
use Modules\Billing\Service\WishlistService; | ||
use Modules\Core\Helpers\Helper; | ||
use Modules\Core\Traits\ApiResponses; | ||
|
||
class WishlistController extends Controller | ||
{ | ||
use ApiResponses; | ||
|
||
private WishlistService $wishlist_service; | ||
|
||
public function __construct(WishlistService $wishlist_service) | ||
{ | ||
$this->wishlist_service = $wishlist_service; | ||
} | ||
|
||
/** | ||
* @return ResourceCollection | ||
*/ | ||
public function index(): ResourceCollection | ||
{ | ||
return WishlistResource::collection($this->wishlist_service->getAll()); | ||
} | ||
|
||
/** | ||
* @param Store $request | ||
* | ||
* @return mixed | ||
* @throws Exception | ||
*/ | ||
public function store(Store $request) | ||
{ | ||
try { | ||
return $this | ||
->setMessage( | ||
__( | ||
'apiResponse.storeSuccess', | ||
[ | ||
'resource' => Helper::getResourceName( | ||
$this->wishlist_service->wishlist_repository->model | ||
), | ||
] | ||
) | ||
) | ||
->respond(new WishlistResource($this->wishlist_service->store($request->all()))); | ||
} catch (Exception $exception) { | ||
return $exception->getMessage(); | ||
} | ||
} | ||
|
||
/** | ||
* @param $id | ||
* | ||
* @return JsonResponse|string | ||
*/ | ||
public function destroy($id) | ||
{ | ||
try { | ||
return $this | ||
->setMessage( | ||
__( | ||
'apiResponse.deleteSuccess', | ||
[ | ||
'resource' => Helper::getResourceName( | ||
$this->wishlist_service->wishlist_repository->model | ||
), | ||
] | ||
) | ||
) | ||
->respond($this->wishlist_service->destroy($id)); | ||
} catch (Exception $exception) { | ||
return $exception->getMessage(); | ||
} | ||
} | ||
} |
Oops, something went wrong.