Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iqdevTranningProgram
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Адлан Шамавов
iqdevTranningProgram
Commits
7bb55cc3
Commit
7bb55cc3
authored
8 months ago
by
Адлан Шамавов
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
8ee9ca86
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Ptps controller 5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Controller/HomeController.php
+6
-14
6 additions, 14 deletions
src/Controller/HomeController.php
src/Requests/HowDaysToNyRequest.php
+11
-0
11 additions, 0 deletions
src/Requests/HowDaysToNyRequest.php
with
17 additions
and
14 deletions
src/Controller/HomeController.php
+
6
−
14
View file @
7bb55cc3
...
@@ -7,7 +7,8 @@ use App\Requests\{
...
@@ -7,7 +7,8 @@ use App\Requests\{
SortPriceRequest
,
SortPriceRequest
,
SearchRequest
,
SearchRequest
,
UniqElementsRequest
,
UniqElementsRequest
,
MenuRequest
MenuRequest
,
HowDaysToNyRequest
};
};
use
DateTimeImmutable
;
use
DateTimeImmutable
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
...
@@ -48,21 +49,12 @@ class HomeController extends AbstractController
...
@@ -48,21 +49,12 @@ class HomeController extends AbstractController
return
$this
->
json
(
$result
);
return
$this
->
json
(
$result
);
}
}
#
[
Route
(
#[Route('/howDaysToNy', name: 'howDaysToNy', methods: ['GET'])]
'/howDaysToNy/{day}/{month}/{year}'
,
public
function
howDaysToNy
(
HowDaysToNyRequest
$request
):
Response
name
:
'howDaysToNy'
,
requirements
:
[
'day'
=>
'(?<!-)(?<!\d)\d+'
,
'month'
=>
'(?<!-)(?<!\d)\d+'
,
'year'
=>
'(?<!-)(?<!\d)\d+'
],
methods
:
[
'GET'
]
)]
public
function
howDaysToNy
(
int
$day
,
int
$month
,
int
$year
):
Response
{
{
$date
AsString
=
$year
.
"-"
.
$month
.
"-"
.
$day
;
$date
=
$request
->
getRequest
()
->
get
(
'date'
)
;
try
{
try
{
$result
=
$this
->
functions
->
howDaysToNy
(
new
DateTimeImmutable
(
$date
AsString
));
$result
=
$this
->
functions
->
howDaysToNy
(
new
DateTimeImmutable
(
$date
));
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
return
new
Response
(
$e
->
getMessage
());
return
new
Response
(
$e
->
getMessage
());
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Requests/HowDaysToNyRequest.php
0 → 100644
+
11
−
0
View file @
7bb55cc3
<?php
namespace
App\Requests
;
use
Symfony\Component\Validator\Constraints
as
Assert
;
class
HowDaysToNyRequest
extends
BaseRequest
{
#[Assert\Type('date')]
public
$date
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment