-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
473 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace Controllers\Order | ||
{ | ||
|
||
use Controllers\BaseController; | ||
use HttpException; | ||
use Models\Exceptions\CustomException; | ||
use Models\ViewModels\NewOrderViewModel; | ||
use Services\AuthService; | ||
use Services\DVDService; | ||
use Utils\JWTUtils; | ||
use Views\Order\NewOrder\NewOrderView; | ||
|
||
class NewOrderController extends BaseController { | ||
|
||
function __construct() | ||
{ | ||
JWTUtils::isAuthorized(); | ||
} | ||
|
||
public function get(): void | ||
{ | ||
$data = new NewOrderViewModel(); | ||
$service = new DVDService(); | ||
$userService = new AuthService(); | ||
|
||
$userId = JWTUtils::getValue($_COOKIE["jwt"], "userId"); | ||
|
||
$data->Articles = []; | ||
$data->TotalPrice = 0; | ||
$data->User = $userService->getUserById($userId); | ||
|
||
if(isset($_COOKIE["cart"])) | ||
{ | ||
$cart = json_decode($_COOKIE["cart"]); | ||
foreach($cart->articles as $article) | ||
{ | ||
$dvd = $service->getById($article->articleId); | ||
$data->Articles[] = $dvd; | ||
$data->TotalPrice += $dvd->price; | ||
} | ||
} | ||
|
||
$view = new NewOrderView($data); | ||
$view->render(); | ||
} | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
namespace Controllers\Search | ||
{ | ||
|
||
use Controllers\BaseController; | ||
use Models\CollectionTypeEnum; | ||
use Models\DVDCollection; | ||
use Models\QueryModel\HomeQueryModel; | ||
use Models\ViewModels\SearchViewModel; | ||
use Services\DVDService; | ||
use Views\Search\SearchView; | ||
|
||
class SearchController extends BaseController { | ||
public function get(): void | ||
{ | ||
$data = new SearchViewModel(); | ||
$service = new DVDService(); | ||
|
||
$queryModel = new HomeQueryModel(); | ||
if(!empty($_GET)) | ||
{ | ||
$queryModel->setFromQueryString($_GET); | ||
} | ||
else | ||
{ | ||
header('Location: ' . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH)."?".$queryModel->getQueryString(), true, 303); | ||
die(); | ||
} | ||
|
||
$queryModel->Limit = 99; | ||
$data->Query = $queryModel; | ||
$data->DVDs = $service->getAll($queryModel, true); | ||
|
||
$view = new SearchView($data); | ||
$view->render(); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
<?php | ||
|
||
namespace Models\Exceptions | ||
{ | ||
|
||
class CustomException extends \Exception | ||
{ | ||
function __construct(int $code, string $message) | ||
{ | ||
parent::__construct($code . ": " . $message); | ||
} | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
<?php | ||
namespace Models\ViewModels | ||
{ | ||
|
||
use Interfaces\IViewModel; | ||
use Models\UserModel; | ||
|
||
class NewOrderViewModel implements IViewModel | ||
{ | ||
function __construct() | ||
{ | ||
|
||
} | ||
public array $Articles; | ||
public float $TotalPrice; | ||
public UserModel $User; | ||
} | ||
|
||
} | ||
|
||
|
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
Oops, something went wrong.