mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Added time entry api endpoints; Increased phpstan level; renamed to solidtime
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
APP_NAME=Laravel
|
APP_NAME=solidtime
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=base64:UNQNf1SXeASNkWux01Rj8EnHYx8FO0kAxWNDwktclkk=
|
APP_KEY=base64:UNQNf1SXeASNkWux01Rj8EnHYx8FO0kAxWNDwktclkk=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=https://solidtime.test
|
||||||
|
APP_FORCE_HTTPS=true
|
||||||
|
|
||||||
SUPER_ADMINS=admin@example.com
|
SUPER_ADMINS=admin@example.com
|
||||||
|
|
||||||
@@ -60,6 +61,6 @@ VITE_PUSHER_PORT="${PUSHER_PORT}"
|
|||||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
||||||
NGINX_HOST_NAME=timetracker.test
|
NGINX_HOST_NAME=solidtime.test
|
||||||
NETWORK_NAME=reverse-proxy-docker-traefik_routing
|
NETWORK_NAME=reverse-proxy-docker-traefik_routing
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
GNU Affero General Public License
|
||||||
Version 3, 19 November 2007
|
=================================
|
||||||
|
|
||||||
|
_Version 3, 19 November 2007_
|
||||||
|
_Copyright © 2007 Free Software Foundation, Inc. <<http://fsf.org/>>_
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
## Preamble
|
||||||
|
|
||||||
The GNU Affero General Public License is a free, copyleft license for
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
software and other kinds of works, specifically designed to ensure
|
software and other kinds of works, specifically designed to ensure
|
||||||
@@ -25,7 +27,7 @@ want it, that you can change the software or use pieces of it in new
|
|||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
Developers that use our General Public Licenses protect your rights
|
Developers that use our General Public Licenses protect your rights
|
||||||
with two steps: (1) assert copyright on the software, and (2) offer
|
with two steps: **(1)** assert copyright on the software, and **(2)** offer
|
||||||
you this License which gives you legal permission to copy, distribute
|
you this License which gives you legal permission to copy, distribute
|
||||||
and/or modify the software.
|
and/or modify the software.
|
||||||
|
|
||||||
@@ -56,70 +58,70 @@ this license.
|
|||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
## TERMS AND CONDITIONS
|
||||||
|
|
||||||
0. Definitions.
|
### 0. Definitions
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
“This License” refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
“Copyright” also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
“The Program” refers to any copyrightable work licensed under this
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
License. Each licensee is addressed as “you”. “Licensees” and
|
||||||
"recipients" may be individuals or organizations.
|
“recipients” may be individuals or organizations.
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
To “modify” a work means to copy from or adapt all or part of the work
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
exact copy. The resulting work is called a “modified version” of the
|
||||||
earlier work or a work "based on" the earlier work.
|
earlier work or a work “based on” the earlier work.
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A “covered work” means either the unmodified Program or a work based
|
||||||
on the Program.
|
on the Program.
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
To “propagate” a work means to do anything with it that, without
|
||||||
permission, would make you directly or secondarily liable for
|
permission, would make you directly or secondarily liable for
|
||||||
infringement under applicable copyright law, except executing it on a
|
infringement under applicable copyright law, except executing it on a
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
distribution (with or without modification), making available to the
|
distribution (with or without modification), making available to the
|
||||||
public, and in some countries other activities as well.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
To “convey” a work means any kind of propagation that enables other
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
An interactive user interface displays “Appropriate Legal Notices”
|
||||||
to the extent that it includes a convenient and prominently visible
|
to the extent that it includes a convenient and prominently visible
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
feature that **(1)** displays an appropriate copyright notice, and **(2)**
|
||||||
tells the user that there is no warranty for the work (except to the
|
tells the user that there is no warranty for the work (except to the
|
||||||
extent that warranties are provided), that licensees may convey the
|
extent that warranties are provided), that licensees may convey the
|
||||||
work under this License, and how to view a copy of this License. If
|
work under this License, and how to view a copy of this License. If
|
||||||
the interface presents a list of user commands or options, such as a
|
the interface presents a list of user commands or options, such as a
|
||||||
menu, a prominent item in the list meets this criterion.
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
1. Source Code.
|
### 1. Source Code
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
The “source code” for a work means the preferred form of the work
|
||||||
for making modifications to it. "Object code" means any non-source
|
for making modifications to it. “Object code” means any non-source
|
||||||
form of a work.
|
form of a work.
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
A “Standard Interface” means an interface that either is an official
|
||||||
standard defined by a recognized standards body, or, in the case of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
interfaces specified for a particular programming language, one that
|
interfaces specified for a particular programming language, one that
|
||||||
is widely used among developers working in that language.
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
The “System Libraries” of an executable work include anything, other
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
than the work as a whole, that **(a)** is included in the normal form of
|
||||||
packaging a Major Component, but which is not part of that Major
|
packaging a Major Component, but which is not part of that Major
|
||||||
Component, and (b) serves only to enable use of the work with that
|
Component, and **(b)** serves only to enable use of the work with that
|
||||||
Major Component, or to implement a Standard Interface for which an
|
Major Component, or to implement a Standard Interface for which an
|
||||||
implementation is available to the public in source code form. A
|
implementation is available to the public in source code form. A
|
||||||
"Major Component", in this context, means a major essential component
|
“Major Component”, in this context, means a major essential component
|
||||||
(kernel, window system, and so on) of the specific operating system
|
(kernel, window system, and so on) of the specific operating system
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
produce the work, or an object code interpreter used to run it.
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
The “Corresponding Source” for a work in object code form means all
|
||||||
the source code needed to generate, install, and (for an executable
|
the source code needed to generate, install, and (for an executable
|
||||||
work) run the object code and to modify the work, including scripts to
|
work) run the object code and to modify the work, including scripts to
|
||||||
control those activities. However, it does not include the work's
|
control those activities. However, it does not include the work's
|
||||||
@@ -139,7 +141,7 @@ Source.
|
|||||||
The Corresponding Source for a work in source code form is that
|
The Corresponding Source for a work in source code form is that
|
||||||
same work.
|
same work.
|
||||||
|
|
||||||
2. Basic Permissions.
|
### 2. Basic Permissions
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
All rights granted under this License are granted for the term of
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
@@ -164,7 +166,7 @@ Conveying under any other circumstances is permitted solely under
|
|||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
makes it unnecessary.
|
makes it unnecessary.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
No covered work shall be deemed part of an effective technological
|
||||||
measure under any applicable law fulfilling obligations under article
|
measure under any applicable law fulfilling obligations under article
|
||||||
@@ -180,7 +182,7 @@ modification of the work as a means of enforcing, against the work's
|
|||||||
users, your or third parties' legal rights to forbid circumvention of
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
technological measures.
|
technological measures.
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
### 4. Conveying Verbatim Copies
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
You may convey verbatim copies of the Program's source code as you
|
||||||
receive it, in any medium, provided that you conspicuously and
|
receive it, in any medium, provided that you conspicuously and
|
||||||
@@ -193,101 +195,94 @@ recipients a copy of this License along with the Program.
|
|||||||
You may charge any price or no price for each copy that you convey,
|
You may charge any price or no price for each copy that you convey,
|
||||||
and you may offer support or warranty protection for a fee.
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
### 5. Conveying Modified Source Versions
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
You may convey a work based on the Program, or the modifications to
|
||||||
produce it from the Program, in the form of source code under the
|
produce it from the Program, in the form of source code under the
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
* **a)** The work must carry prominent notices stating that you modified
|
||||||
it, and giving a relevant date.
|
it, and giving a relevant date.
|
||||||
|
* **b)** The work must carry prominent notices stating that it is
|
||||||
b) The work must carry prominent notices stating that it is
|
released under this License and any conditions added under section 7.
|
||||||
released under this License and any conditions added under section
|
This requirement modifies the requirement in section 4 to
|
||||||
7. This requirement modifies the requirement in section 4 to
|
“keep intact all notices”.
|
||||||
"keep intact all notices".
|
* **c)** You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
c) You must license the entire work, as a whole, under this
|
License will therefore apply, along with any applicable section 7
|
||||||
License to anyone who comes into possession of a copy. This
|
additional terms, to the whole of the work, and all its parts,
|
||||||
License will therefore apply, along with any applicable section 7
|
regardless of how they are packaged. This License gives no
|
||||||
additional terms, to the whole of the work, and all its parts,
|
permission to license the work in any other way, but it does not
|
||||||
regardless of how they are packaged. This License gives no
|
invalidate such permission if you have separately received it.
|
||||||
permission to license the work in any other way, but it does not
|
* **d)** If the work has interactive user interfaces, each must display
|
||||||
invalidate such permission if you have separately received it.
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
d) If the work has interactive user interfaces, each must display
|
work need not make them do so.
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
A compilation of a covered work with other separate and independent
|
||||||
works, which are not by their nature extensions of the covered work,
|
works, which are not by their nature extensions of the covered work,
|
||||||
and which are not combined with it such as to form a larger program,
|
and which are not combined with it such as to form a larger program,
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
“aggregate” if the compilation and its resulting copyright are not
|
||||||
used to limit the access or legal rights of the compilation's users
|
used to limit the access or legal rights of the compilation's users
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
in an aggregate does not cause this License to apply to the other
|
in an aggregate does not cause this License to apply to the other
|
||||||
parts of the aggregate.
|
parts of the aggregate.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
### 6. Conveying Non-Source Forms
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
You may convey a covered work in object code form under the terms
|
||||||
of sections 4 and 5, provided that you also convey the
|
of sections 4 and 5, provided that you also convey the
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
in one of these ways:
|
in one of these ways:
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
* **a)** Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by the
|
(including a physical distribution medium), accompanied by the
|
||||||
Corresponding Source fixed on a durable physical medium
|
Corresponding Source fixed on a durable physical medium
|
||||||
customarily used for software interchange.
|
customarily used for software interchange.
|
||||||
|
* **b)** Convey the object code in, or embodied in, a physical product
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
(including a physical distribution medium), accompanied by a
|
||||||
(including a physical distribution medium), accompanied by a
|
written offer, valid for at least three years and valid for as
|
||||||
written offer, valid for at least three years and valid for as
|
long as you offer spare parts or customer support for that product
|
||||||
long as you offer spare parts or customer support for that product
|
model, to give anyone who possesses the object code either **(1)** a
|
||||||
model, to give anyone who possesses the object code either (1) a
|
copy of the Corresponding Source for all the software in the
|
||||||
copy of the Corresponding Source for all the software in the
|
product that is covered by this License, on a durable physical
|
||||||
product that is covered by this License, on a durable physical
|
medium customarily used for software interchange, for a price no
|
||||||
medium customarily used for software interchange, for a price no
|
more than your reasonable cost of physically performing this
|
||||||
more than your reasonable cost of physically performing this
|
conveying of source, or **(2)** access to copy the
|
||||||
conveying of source, or (2) access to copy the
|
Corresponding Source from a network server at no charge.
|
||||||
Corresponding Source from a network server at no charge.
|
* **c)** Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
c) Convey individual copies of the object code with a copy of the
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
written offer to provide the Corresponding Source. This
|
only if you received the object code with such an offer, in accord
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
with subsection 6b.
|
||||||
only if you received the object code with such an offer, in accord
|
* **d)** Convey the object code by offering access from a designated
|
||||||
with subsection 6b.
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
d) Convey the object code by offering access from a designated
|
further charge. You need not require recipients to copy the
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
Corresponding Source along with the object code. If the place to
|
||||||
Corresponding Source in the same way through the same place at no
|
copy the object code is a network server, the Corresponding Source
|
||||||
further charge. You need not require recipients to copy the
|
may be on a different server (operated by you or a third party)
|
||||||
Corresponding Source along with the object code. If the place to
|
that supports equivalent copying facilities, provided you maintain
|
||||||
copy the object code is a network server, the Corresponding Source
|
clear directions next to the object code saying where to find the
|
||||||
may be on a different server (operated by you or a third party)
|
Corresponding Source. Regardless of what server hosts the
|
||||||
that supports equivalent copying facilities, provided you maintain
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
clear directions next to the object code saying where to find the
|
available for as long as needed to satisfy these requirements.
|
||||||
Corresponding Source. Regardless of what server hosts the
|
* **e)** Convey the object code using peer-to-peer transmission, provided
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
you inform other peers where the object code and Corresponding
|
||||||
available for as long as needed to satisfy these requirements.
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
A separable portion of the object code, whose source code is excluded
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
included in conveying the object code work.
|
included in conveying the object code work.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
A “User Product” is either **(1)** a “consumer product”, which means any
|
||||||
tangible personal property which is normally used for personal, family,
|
tangible personal property which is normally used for personal, family,
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
or household purposes, or **(2)** anything designed or sold for incorporation
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
product received by a particular user, "normally used" refers to a
|
product received by a particular user, “normally used” refers to a
|
||||||
typical or common use of that class of product, regardless of the status
|
typical or common use of that class of product, regardless of the status
|
||||||
of the particular user or of the way in which the particular user
|
of the particular user or of the way in which the particular user
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
@@ -295,7 +290,7 @@ is a consumer product regardless of whether the product has substantial
|
|||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
the only significant mode of use of the product.
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
“Installation Information” for a User Product means any methods,
|
||||||
procedures, authorization keys, or other information required to install
|
procedures, authorization keys, or other information required to install
|
||||||
and execute modified versions of a covered work in that User Product from
|
and execute modified versions of a covered work in that User Product from
|
||||||
a modified version of its Corresponding Source. The information must
|
a modified version of its Corresponding Source. The information must
|
||||||
@@ -328,9 +323,9 @@ documented (and with an implementation available to the public in
|
|||||||
source code form), and must require no special password or key for
|
source code form), and must require no special password or key for
|
||||||
unpacking, reading or copying.
|
unpacking, reading or copying.
|
||||||
|
|
||||||
7. Additional Terms.
|
### 7. Additional Terms
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
“Additional permissions” are terms that supplement the terms of this
|
||||||
License by making exceptions from one or more of its conditions.
|
License by making exceptions from one or more of its conditions.
|
||||||
Additional permissions that are applicable to the entire Program shall
|
Additional permissions that are applicable to the entire Program shall
|
||||||
be treated as though they were included in this License, to the extent
|
be treated as though they were included in this License, to the extent
|
||||||
@@ -350,31 +345,26 @@ Notwithstanding any other provision of this License, for material you
|
|||||||
add to a covered work, you may (if authorized by the copyright holders of
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
that material) supplement the terms of this License with terms:
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
* **a)** Disclaiming warranty or limiting liability differently from the
|
||||||
terms of sections 15 and 16 of this License; or
|
terms of sections 15 and 16 of this License; or
|
||||||
|
* **b)** Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
* **c)** Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
* **d)** Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
* **e)** Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
* **f)** Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
All other non-permissive additional terms are considered “further
|
||||||
author attributions in that material or in the Appropriate Legal
|
restrictions” within the meaning of section 10. If the Program as you
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
received it, or any part of it, contains a notice stating that it is
|
||||||
governed by this License along with a term that is a further
|
governed by this License along with a term that is a further
|
||||||
restriction, you may remove that term. If a license document contains
|
restriction, you may remove that term. If a license document contains
|
||||||
@@ -392,7 +382,7 @@ Additional terms, permissive or non-permissive, may be stated in the
|
|||||||
form of a separately written license, or stated as exceptions;
|
form of a separately written license, or stated as exceptions;
|
||||||
the above requirements apply either way.
|
the above requirements apply either way.
|
||||||
|
|
||||||
8. Termination.
|
### 8. Termination
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
You may not propagate or modify a covered work except as expressly
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
@@ -401,9 +391,9 @@ this License (including any patent licenses granted under the third
|
|||||||
paragraph of section 11).
|
paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
However, if you cease all violation of this License, then your
|
||||||
license from a particular copyright holder is reinstated (a)
|
license from a particular copyright holder is reinstated **(a)**
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
finally terminates your license, and **(b)** permanently, if the copyright
|
||||||
holder fails to notify you of the violation by some reasonable means
|
holder fails to notify you of the violation by some reasonable means
|
||||||
prior to 60 days after the cessation.
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
@@ -420,7 +410,7 @@ this License. If your rights have been terminated and not permanently
|
|||||||
reinstated, you do not qualify to receive new licenses for the same
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
material under section 10.
|
material under section 10.
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
### 9. Acceptance Not Required for Having Copies
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
You are not required to accept this License in order to receive or
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
@@ -431,14 +421,14 @@ modify any covered work. These actions infringe copyright if you do
|
|||||||
not accept this License. Therefore, by modifying or propagating a
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
### 10. Automatic Licensing of Downstream Recipients
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
Each time you convey a covered work, the recipient automatically
|
||||||
receives a license from the original licensors, to run, modify and
|
receives a license from the original licensors, to run, modify and
|
||||||
propagate that work, subject to this License. You are not responsible
|
propagate that work, subject to this License. You are not responsible
|
||||||
for enforcing compliance by third parties with this License.
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
An “entity transaction” is a transaction transferring control of an
|
||||||
organization, or substantially all assets of one, or subdividing an
|
organization, or substantially all assets of one, or subdividing an
|
||||||
organization, or merging organizations. If propagation of a covered
|
organization, or merging organizations. If propagation of a covered
|
||||||
work results from an entity transaction, each party to that
|
work results from an entity transaction, each party to that
|
||||||
@@ -456,19 +446,19 @@ rights granted under this License, and you may not initiate litigation
|
|||||||
any patent claim is infringed by making, using, selling, offering for
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
sale, or importing the Program or any portion of it.
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
11. Patents.
|
### 11. Patents
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
A “contributor” is a copyright holder who authorizes use under this
|
||||||
License of the Program or a work on which the Program is based. The
|
License of the Program or a work on which the Program is based. The
|
||||||
work thus licensed is called the contributor's "contributor version".
|
work thus licensed is called the contributor's “contributor version”.
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
A contributor's “essential patent claims” are all patent claims
|
||||||
owned or controlled by the contributor, whether already acquired or
|
owned or controlled by the contributor, whether already acquired or
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
by this License, of making, using, or selling its contributor version,
|
by this License, of making, using, or selling its contributor version,
|
||||||
but do not include claims that would be infringed only as a
|
but do not include claims that would be infringed only as a
|
||||||
consequence of further modification of the contributor version. For
|
consequence of further modification of the contributor version. For
|
||||||
purposes of this definition, "control" includes the right to grant
|
purposes of this definition, “control” includes the right to grant
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
this License.
|
this License.
|
||||||
|
|
||||||
@@ -477,10 +467,10 @@ patent license under the contributor's essential patent claims, to
|
|||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
propagate the contents of its contributor version.
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
In the following three paragraphs, a “patent license” is any express
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
(such as an express permission to practice a patent or covenant not to
|
(such as an express permission to practice a patent or covenant not to
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
sue for patent infringement). To “grant” such a patent license to a
|
||||||
party means to make such an agreement or commitment not to enforce a
|
party means to make such an agreement or commitment not to enforce a
|
||||||
patent against the party.
|
patent against the party.
|
||||||
|
|
||||||
@@ -488,11 +478,11 @@ If you convey a covered work, knowingly relying on a patent license,
|
|||||||
and the Corresponding Source of the work is not available for anyone
|
and the Corresponding Source of the work is not available for anyone
|
||||||
to copy, free of charge and under the terms of this License, through a
|
to copy, free of charge and under the terms of this License, through a
|
||||||
publicly available network server or other readily accessible means,
|
publicly available network server or other readily accessible means,
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
then you must either **(1)** cause the Corresponding Source to be so
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
available, or **(2)** arrange to deprive yourself of the benefit of the
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
patent license for this particular work, or **(3)** arrange, in a manner
|
||||||
consistent with the requirements of this License, to extend the patent
|
consistent with the requirements of this License, to extend the patent
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
license to downstream recipients. “Knowingly relying” means you have
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
covered work in a country, or your recipient's use of the covered work
|
covered work in a country, or your recipient's use of the covered work
|
||||||
in a country, would infringe one or more identifiable patents in that
|
in a country, would infringe one or more identifiable patents in that
|
||||||
@@ -506,7 +496,7 @@ or convey a specific copy of the covered work, then the patent license
|
|||||||
you grant is automatically extended to all recipients of the covered
|
you grant is automatically extended to all recipients of the covered
|
||||||
work and works based on it.
|
work and works based on it.
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
A patent license is “discriminatory” if it does not include within
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
specifically granted under this License. You may not convey a covered
|
specifically granted under this License. You may not convey a covered
|
||||||
@@ -515,8 +505,8 @@ in the business of distributing software, under which you make payment
|
|||||||
to the third party based on the extent of your activity of conveying
|
to the third party based on the extent of your activity of conveying
|
||||||
the work, and under which the third party grants, to any of the
|
the work, and under which the third party grants, to any of the
|
||||||
parties who would receive the covered work from you, a discriminatory
|
parties who would receive the covered work from you, a discriminatory
|
||||||
patent license (a) in connection with copies of the covered work
|
patent license **(a)** in connection with copies of the covered work
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
conveyed by you (or copies made from those copies), or **(b)** primarily
|
||||||
for and in connection with specific products or compilations that
|
for and in connection with specific products or compilations that
|
||||||
contain the covered work, unless you entered into that arrangement,
|
contain the covered work, unless you entered into that arrangement,
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
@@ -525,7 +515,7 @@ Nothing in this License shall be construed as excluding or limiting
|
|||||||
any implied license or other defenses to infringement that may
|
any implied license or other defenses to infringement that may
|
||||||
otherwise be available to you under applicable patent law.
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
### 12. No Surrender of Others' Freedom
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
@@ -537,7 +527,7 @@ to collect a royalty for further conveying from those to whom you convey
|
|||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
### 13. Remote Network Interaction; Use with the GNU General Public License
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, if you modify the
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
Program, your modified version must prominently offer all users
|
Program, your modified version must prominently offer all users
|
||||||
@@ -558,7 +548,7 @@ License will continue to apply to the part which is the covered work,
|
|||||||
but the work with which it is combined will remain governed by version
|
but the work with which it is combined will remain governed by version
|
||||||
3 of the GNU General Public License.
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
### 14. Revised Versions of this License
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU Affero General Public License from time to time. Such new versions
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
@@ -567,7 +557,7 @@ address new problems or concerns.
|
|||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU Affero General
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License “or any later version” applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
@@ -584,18 +574,18 @@ permissions. However, no additional obligations are imposed on any
|
|||||||
author or copyright holder as a result of your choosing to follow a
|
author or copyright holder as a result of your choosing to follow a
|
||||||
later version.
|
later version.
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
### 15. Disclaimer of Warranty
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
### 16. Limitation of Liability
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
@@ -607,7 +597,7 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
SUCH DAMAGES.
|
SUCH DAMAGES.
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
### 17. Interpretation of Sections 15 and 16
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
above cannot be given local legal effect according to their terms,
|
above cannot be given local legal effect according to their terms,
|
||||||
@@ -616,9 +606,9 @@ an absolute waiver of all civil liability in connection with the
|
|||||||
Program, unless a warranty or assumption of liability accompanies a
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
copy of the Program in return for a fee.
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
_END OF TERMS AND CONDITIONS_
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
## How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
@@ -627,10 +617,9 @@ free software which everyone can redistribute and change under these terms.
|
|||||||
To do so, attach the following notices to the program. It is safest
|
To do so, attach the following notices to the program. It is safest
|
||||||
to attach them to the start of each source file to most effectively
|
to attach them to the start of each source file to most effectively
|
||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
|
||||||
Copyright (C) 2024 Gregor Vostrak & Constantin Graf
|
Copyright (C) 2024 Gregor Vostrak & Constantin Graf
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@@ -651,12 +640,12 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
If your software can interact with users remotely through a computer
|
If your software can interact with users remotely through a computer
|
||||||
network, you should also make sure that it provides a way for users to
|
network, you should also make sure that it provides a way for users to
|
||||||
get its source. For example, if your program is a web application, its
|
get its source. For example, if your program is a web application, its
|
||||||
interface could display a "Source" link that leads users to an archive
|
interface could display a “Source” link that leads users to an archive
|
||||||
of the code. There are many ways you could offer source, and different
|
of the code. There are many ways you could offer source, and different
|
||||||
solutions will be better for different programs; see section 13 for the
|
solutions will be better for different programs; see section 13 for the
|
||||||
specific requirements.
|
specific requirements.
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a “copyright disclaimer” for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<<http://www.gnu.org/licenses/>>.
|
||||||
@@ -34,13 +34,13 @@ Additional System Requirements:
|
|||||||
Add the following entry to your `/etc/hosts`
|
Add the following entry to your `/etc/hosts`
|
||||||
|
|
||||||
```
|
```
|
||||||
127.0.0.1 timetracker.test
|
127.0.0.1 solidtime.test
|
||||||
127.0.0.1 playwright.timetracker.test
|
127.0.0.1 playwright.solidtime.test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running E2E Tests
|
## Running E2E Tests
|
||||||
|
|
||||||
`./vendor/bin/sail up -d ` will automatically start a Playwright UI server that you can access at `https://playwright.timetracker.test`.
|
`./vendor/bin/sail up -d ` will automatically start a Playwright UI server that you can access at `https://playwright.solidtime.test`.
|
||||||
Make sure that you use HTTPS otherwise the resources will not be loaded correctly.
|
Make sure that you use HTTPS otherwise the resources will not be loaded correctly.
|
||||||
|
|
||||||
## Recording E2E Tests
|
## Recording E2E Tests
|
||||||
@@ -49,7 +49,7 @@ To record E2E tests, you need to install and execute playwright locally (outside
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx playwright install
|
npx playwright install
|
||||||
npx playwright codegen timetracker.test
|
npx playwright codegen solidtime.test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
use Illuminate\Validation\Rules\Password;
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
trait PasswordValidationRules
|
trait PasswordValidationRules
|
||||||
@@ -11,7 +12,7 @@ trait PasswordValidationRules
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules used to validate passwords.
|
* Get the validation rules used to validate passwords.
|
||||||
*
|
*
|
||||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array|string>
|
* @return array<int, Rule|string>
|
||||||
*/
|
*/
|
||||||
protected function passwordRules(): array
|
protected function passwordRules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Actions\Jetstream;
|
|||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Laravel\Jetstream\Contracts\AddsTeamMembers;
|
use Laravel\Jetstream\Contracts\AddsTeamMembers;
|
||||||
@@ -55,7 +56,7 @@ class AddOrganizationMember implements AddsTeamMembers
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules for adding a team member.
|
* Get the validation rules for adding a team member.
|
||||||
*
|
*
|
||||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
* @return array<string, array<Rule|string>>
|
||||||
*/
|
*/
|
||||||
protected function rules(): array
|
protected function rules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Models\Organization;
|
|||||||
use App\Models\OrganizationInvitation;
|
use App\Models\OrganizationInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
@@ -59,7 +60,7 @@ class InviteOrganizationMember implements InvitesTeamMembers
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules for inviting a team member.
|
* Get the validation rules for inviting a team member.
|
||||||
*
|
*
|
||||||
* @return array<string, ValidationRule|array|string>
|
* @return array<string, array<ValidationRule|Rule|string>>
|
||||||
*/
|
*/
|
||||||
protected function rules(Organization $organization): array
|
protected function rules(Organization $organization): array
|
||||||
{
|
{
|
||||||
|
|||||||
24
app/Exceptions/ApiException.php
Normal file
24
app/Exceptions/ApiException.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ApiException extends Exception
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Render the exception into an HTTP response.
|
||||||
|
*/
|
||||||
|
public function render(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return response()
|
||||||
|
->json([
|
||||||
|
'error' => true,
|
||||||
|
'message' => $this->getMessage(),
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/Exceptions/TimeEntryStillRunning.php
Normal file
9
app/Exceptions/TimeEntryStillRunning.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
class TimeEntryStillRunning extends ApiException
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -25,15 +25,16 @@ class OrganizationResource extends Resource
|
|||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
|
->columns(1)
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->label('Name')
|
->label('Name')
|
||||||
->required()
|
->required()
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
Forms\Components\Toggle::make('Is personal?')
|
Forms\Components\Toggle::make('personal_team')
|
||||||
->label('Is personal?')
|
->label('Is personal?')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('owner_id')
|
Forms\Components\Select::make('user_id')
|
||||||
->relationship(name: 'owner', titleAttribute: 'email')
|
->relationship(name: 'owner', titleAttribute: 'email')
|
||||||
->searchable(['name', 'email'])
|
->searchable(['name', 'email'])
|
||||||
->required(),
|
->required(),
|
||||||
@@ -47,7 +48,8 @@ class OrganizationResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\ToggleColumn::make('is_personal')
|
Tables\Columns\IconColumn::make('personal_team')
|
||||||
|
->boolean()
|
||||||
->label('Is personal?')
|
->label('Is personal?')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('owner.email')
|
Tables\Columns\TextColumn::make('owner.email')
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class UserResource extends Resource
|
|||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
|
->columns(1)
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->label('ID')
|
->label('ID')
|
||||||
|
|||||||
@@ -11,11 +11,22 @@ use App\Http\Resources\V1\Project\ProjectResource;
|
|||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class ProjectController extends Controller
|
class ProjectController extends Controller
|
||||||
{
|
{
|
||||||
|
protected function checkPermission(Organization $organization, string $permission, ?Project $project = null): void
|
||||||
|
{
|
||||||
|
parent::checkPermission($organization, $permission);
|
||||||
|
if ($project !== null && $project->organization_id !== $organization->id) {
|
||||||
|
throw new AuthorizationException('Project does not belong to organization');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get projects
|
||||||
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function index(Organization $organization): JsonResource
|
public function index(Organization $organization): JsonResource
|
||||||
@@ -29,17 +40,22 @@ class ProjectController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get project
|
||||||
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function show(Organization $organization, Project $project): JsonResource
|
public function show(Organization $organization, Project $project): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'projects:view');
|
$this->checkPermission($organization, 'projects:view', $project);
|
||||||
|
|
||||||
$project->load('organization');
|
$project->load('organization');
|
||||||
|
|
||||||
return new ProjectResource($project);
|
return new ProjectResource($project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Create project
|
||||||
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function store(Organization $organization, ProjectStoreRequest $request): JsonResource
|
public function store(Organization $organization, ProjectStoreRequest $request): JsonResource
|
||||||
@@ -55,11 +71,13 @@ class ProjectController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Update project
|
||||||
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function update(Organization $organization, Project $project, ProjectUpdateRequest $request): JsonResource
|
public function update(Organization $organization, Project $project, ProjectUpdateRequest $request): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'projects:update');
|
$this->checkPermission($organization, 'projects:update', $project);
|
||||||
$project->name = $request->input('name');
|
$project->name = $request->input('name');
|
||||||
$project->color = $request->input('color');
|
$project->color = $request->input('color');
|
||||||
$project->save();
|
$project->save();
|
||||||
@@ -68,13 +86,17 @@ class ProjectController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Delete project
|
||||||
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function destroy(Organization $organization, Project $project): JsonResource
|
public function destroy(Organization $organization, Project $project): JsonResponse
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'projects:delete');
|
$this->checkPermission($organization, 'projects:delete', $project);
|
||||||
|
|
||||||
$project->delete();
|
$project->delete();
|
||||||
|
|
||||||
return new ProjectResource($project);
|
return response()
|
||||||
|
->json(null, 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
126
app/Http/Controllers/Api/V1/TimeEntryController.php
Normal file
126
app/Http/Controllers/Api/V1/TimeEntryController.php
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
|
use App\Exceptions\TimeEntryStillRunning;
|
||||||
|
use App\Http\Requests\V1\TimeEntry\TimeEntryIndexRequest;
|
||||||
|
use App\Http\Requests\V1\TimeEntry\TimeEntryStoreRequest;
|
||||||
|
use App\Http\Requests\V1\TimeEntry\TimeEntryUpdateRequest;
|
||||||
|
use App\Http\Resources\V1\TimeEntry\TimeEntryCollection;
|
||||||
|
use App\Http\Resources\V1\TimeEntry\TimeEntryResource;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\TimeEntry;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class TimeEntryController extends Controller
|
||||||
|
{
|
||||||
|
protected function checkPermission(Organization $organization, string $permission, ?TimeEntry $timeEntry = null): void
|
||||||
|
{
|
||||||
|
parent::checkPermission($organization, $permission);
|
||||||
|
if ($timeEntry !== null && $timeEntry->organization_id !== $organization->getKey()) {
|
||||||
|
throw new AuthorizationException('Time entry does not belong to organization');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get time entries
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
*/
|
||||||
|
public function index(Organization $organization, TimeEntryIndexRequest $request): JsonResource
|
||||||
|
{
|
||||||
|
if ($request->has('user_id') && $request->get('user_id') === Auth::id()) {
|
||||||
|
$this->checkPermission($organization, 'time-entries:view:own');
|
||||||
|
} else {
|
||||||
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeEntriesQuery = TimeEntry::query()
|
||||||
|
->whereBelongsTo($organization, 'organization');
|
||||||
|
|
||||||
|
if ($request->has('before')) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('after')) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('user_id')) {
|
||||||
|
$timeEntriesQuery->where('user_id', $request->input('user_id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeEntries = $timeEntriesQuery->get();
|
||||||
|
|
||||||
|
return new TimeEntryCollection($timeEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create time entry
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException|TimeEntryStillRunning
|
||||||
|
*/
|
||||||
|
public function store(Organization $organization, TimeEntryStoreRequest $request): JsonResource
|
||||||
|
{
|
||||||
|
if ($request->get('user_id') === Auth::id()) {
|
||||||
|
$this->checkPermission($organization, 'time-entries:create:own');
|
||||||
|
} else {
|
||||||
|
$this->checkPermission($organization, 'time-entries:create:all');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->get('end') === null && TimeEntry::where('user_id', $request->get('user_id'))->where('end', null)->exists()) {
|
||||||
|
// TODO: documentation
|
||||||
|
throw new TimeEntryStillRunning('User already has an active time entry');
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeEntry = new TimeEntry();
|
||||||
|
$timeEntry->fill($request->validated());
|
||||||
|
$timeEntry->organization()->associate($organization);
|
||||||
|
$timeEntry->save();
|
||||||
|
|
||||||
|
return new TimeEntryResource($timeEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update time entry
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
*/
|
||||||
|
public function update(Organization $organization, TimeEntry $timeEntry, TimeEntryUpdateRequest $request): JsonResource
|
||||||
|
{
|
||||||
|
if ($timeEntry->user_id === Auth::id() && $request->get('user_id') === Auth::id()) {
|
||||||
|
$this->checkPermission($organization, 'time-entries:update:own', $timeEntry);
|
||||||
|
} else {
|
||||||
|
$this->checkPermission($organization, 'time-entries:update:all', $timeEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeEntry->fill($request->validated());
|
||||||
|
$timeEntry->save();
|
||||||
|
|
||||||
|
return new TimeEntryResource($timeEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete time entry
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
*/
|
||||||
|
public function destroy(Organization $organization, TimeEntry $timeEntry): JsonResponse
|
||||||
|
{
|
||||||
|
if ($timeEntry->user_id === Auth::id()) {
|
||||||
|
$this->checkPermission($organization, 'time-entries:delete:own', $timeEntry);
|
||||||
|
} else {
|
||||||
|
$this->checkPermission($organization, 'time-entries:delete:all', $timeEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeEntry->delete();
|
||||||
|
|
||||||
|
return response()
|
||||||
|
->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,8 @@ class HandleInertiaRequests extends Middleware
|
|||||||
* Defines the props that are shared by default.
|
* Defines the props that are shared by default.
|
||||||
*
|
*
|
||||||
* @see https://inertiajs.com/shared-data
|
* @see https://inertiajs.com/shared-data
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function share(Request $request): array
|
public function share(Request $request): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,5 +26,6 @@ class TrustProxies extends Middleware
|
|||||||
Request::HEADER_X_FORWARDED_HOST |
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
Request::HEADER_X_FORWARDED_PORT |
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
Request::HEADER_X_FORWARDED_PROTO |
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
Request::HEADER_X_FORWARDED_AWS_ELB |
|
||||||
|
Request::HEADER_X_FORWARDED_TRAEFIK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ProjectStoreRequest extends FormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, ValidationRule|array<mixed>|string>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ProjectUpdateRequest extends FormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, ValidationRule|array<mixed>|string>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
51
app/Http/Requests/V1/TimeEntry/TimeEntryIndexRequest.php
Normal file
51
app/Http/Requests/V1/TimeEntry/TimeEntryIndexRequest.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property Organization $organization
|
||||||
|
*/
|
||||||
|
class TimeEntryIndexRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string|ValidationRule>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'user_id' => [
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(User::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<User> $builder */
|
||||||
|
return $builder->whereHas('organizations', function (Builder $builder) {
|
||||||
|
/** @var Builder<Organization> $builder */
|
||||||
|
return $builder->whereKey($this->organization->getKey());
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
'before' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'date_format:Y-m-d',
|
||||||
|
'before:after',
|
||||||
|
],
|
||||||
|
'after' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'date_format:Y-m-d',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
83
app/Http/Requests/V1/TimeEntry/TimeEntryStoreRequest.php
Normal file
83
app/Http/Requests/V1/TimeEntry/TimeEntryStoreRequest.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\Tag;
|
||||||
|
use App\Models\Task;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property Organization $organization Organization from model binding
|
||||||
|
*/
|
||||||
|
class TimeEntryStoreRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string|ValidationRule>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'user_id' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(User::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<User> $builder */
|
||||||
|
return $builder->whereHas('organizations', function (Builder $builder) {
|
||||||
|
/** @var Builder<Organization> $builder */
|
||||||
|
return $builder->whereKey($this->organization->getKey());
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
'task_id' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(Task::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<Task> $builder */
|
||||||
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
|
'start' => [
|
||||||
|
'required',
|
||||||
|
'date', // TODO
|
||||||
|
],
|
||||||
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
|
'end' => [
|
||||||
|
'required',
|
||||||
|
'nullable',
|
||||||
|
'date', // TODO
|
||||||
|
'after:start',
|
||||||
|
],
|
||||||
|
// Description of time entry
|
||||||
|
'description' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
],
|
||||||
|
// List of tag IDs
|
||||||
|
'tags' => [
|
||||||
|
'nullable',
|
||||||
|
'array',
|
||||||
|
],
|
||||||
|
'tags.*' => [
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(Tag::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<Tag> $builder */
|
||||||
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/Http/Requests/V1/TimeEntry/TimeEntryUpdateRequest.php
Normal file
70
app/Http/Requests/V1/TimeEntry/TimeEntryUpdateRequest.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\Tag;
|
||||||
|
use App\Models\Task;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property Organization $organization Organization from model binding
|
||||||
|
*/
|
||||||
|
class TimeEntryUpdateRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string|ValidationRule>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'task_id' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(Task::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<Task> $builder */
|
||||||
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
|
'start' => [
|
||||||
|
'required',
|
||||||
|
'date', // TODO
|
||||||
|
],
|
||||||
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
|
'end' => [
|
||||||
|
'required',
|
||||||
|
'nullable',
|
||||||
|
'date', // TODO
|
||||||
|
'after:start',
|
||||||
|
],
|
||||||
|
// Description of time entry
|
||||||
|
'description' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
],
|
||||||
|
// List of tag IDs
|
||||||
|
'tags' => [
|
||||||
|
'nullable',
|
||||||
|
'array',
|
||||||
|
],
|
||||||
|
'tags.*' => [
|
||||||
|
'string',
|
||||||
|
'uuid',
|
||||||
|
new ExistsEloquent(Tag::class, null, function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<Tag> $builder */
|
||||||
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Http/Resources/V1/TimeEntry/TimeEntryCollection.php
Normal file
17
app/Http/Resources/V1/TimeEntry/TimeEntryCollection.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Resources\V1\TimeEntry;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
|
|
||||||
|
class TimeEntryCollection extends ResourceCollection
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The resource that this resource collects.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $collects = TimeEntryResource::class;
|
||||||
|
}
|
||||||
28
app/Http/Resources/V1/TimeEntry/TimeEntryResource.php
Normal file
28
app/Http/Resources/V1/TimeEntry/TimeEntryResource.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Resources\V1\TimeEntry;
|
||||||
|
|
||||||
|
use App\Models\TimeEntry;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property TimeEntry $resource
|
||||||
|
*/
|
||||||
|
class TimeEntryResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, string|boolean|integer>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
/** @var string $id ID of time entry */
|
||||||
|
'id' => $this->resource->id,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,8 @@ class OrganizationInvitation extends JetstreamTeamInvitation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the organization that the invitation belongs to.
|
* Get the organization that the invitation belongs to.
|
||||||
|
*
|
||||||
|
* @return BelongsTo<Organization, OrganizationInvitation>
|
||||||
*/
|
*/
|
||||||
public function organization(): BelongsTo
|
public function organization(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -44,6 +46,8 @@ class OrganizationInvitation extends JetstreamTeamInvitation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the organization that the invitation belongs to.
|
* Get the organization that the invitation belongs to.
|
||||||
|
*
|
||||||
|
* @return BelongsTo<Organization, OrganizationInvitation>
|
||||||
*/
|
*/
|
||||||
public function team(): BelongsTo
|
public function team(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,9 +19,13 @@ use Illuminate\Support\Carbon;
|
|||||||
* @property Carbon|null $end
|
* @property Carbon|null $end
|
||||||
* @property bool $billable
|
* @property bool $billable
|
||||||
* @property array $tags
|
* @property array $tags
|
||||||
|
* @property string $user_id
|
||||||
* @property-read User $user
|
* @property-read User $user
|
||||||
|
* @property string $organization_id
|
||||||
* @property-read Organization $organization
|
* @property-read Organization $organization
|
||||||
|
* @property string|null $project_id
|
||||||
* @property-read Project|null $project
|
* @property-read Project|null $project
|
||||||
|
* @property string|null $task_id
|
||||||
* @property-read Task|null $task
|
* @property-read Task|null $task
|
||||||
*
|
*
|
||||||
* @method static TimeEntryFactory factory()
|
* @method static TimeEntryFactory factory()
|
||||||
|
|||||||
@@ -13,9 +13,15 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Dedoc\Scramble\Scramble;
|
||||||
|
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||||
|
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||||
|
use Dedoc\Scramble\Support\Generator\SecuritySchemes\OAuthFlow;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@@ -55,5 +61,19 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
Section::configureUsing(function (Section $section): void {
|
Section::configureUsing(function (Section $section): void {
|
||||||
$section->columns(1);
|
$section->columns(1);
|
||||||
}, null, true);
|
}, null, true);
|
||||||
|
|
||||||
|
Scramble::extendOpenApi(function (OpenApi $openApi) {
|
||||||
|
$openApi->secure(
|
||||||
|
SecurityScheme::oauth2()
|
||||||
|
->flow('authorizationCode', function (OAuthFlow $flow) {
|
||||||
|
$flow
|
||||||
|
->authorizationUrl('https://solidtime.test/oauth/authorize');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (config('app.force_https', false) || App::isProduction()) {
|
||||||
|
URL::forceScheme('https');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,14 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'projects:create',
|
'projects:create',
|
||||||
'projects:update',
|
'projects:update',
|
||||||
'projects:delete',
|
'projects:delete',
|
||||||
|
'time-entries:view:all',
|
||||||
|
'time-entries:create:all',
|
||||||
|
'time-entries:update:all',
|
||||||
|
'time-entries:delete:all',
|
||||||
|
'time-entries:view:own',
|
||||||
|
'time-entries:create:own',
|
||||||
|
'time-entries:update:own',
|
||||||
|
'time-entries:delete:own',
|
||||||
])->description('Administrator users can perform any action.');
|
])->description('Administrator users can perform any action.');
|
||||||
|
|
||||||
Jetstream::role('manager', 'Manager', [
|
Jetstream::role('manager', 'Manager', [
|
||||||
@@ -63,13 +71,22 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'projects:create',
|
'projects:create',
|
||||||
'projects:update',
|
'projects:update',
|
||||||
'projects:delete',
|
'projects:delete',
|
||||||
|
'time-entries:view:all',
|
||||||
|
'time-entries:create:all',
|
||||||
|
'time-entries:update:all',
|
||||||
|
'time-entries:delete:all',
|
||||||
|
'time-entries:view:own',
|
||||||
|
'time-entries:create:own',
|
||||||
|
'time-entries:update:own',
|
||||||
|
'time-entries:delete:own',
|
||||||
])->description('Editor users have the ability to read, create, and update.');
|
])->description('Editor users have the ability to read, create, and update.');
|
||||||
|
|
||||||
Jetstream::role('employee', 'Employee', [
|
Jetstream::role('employee', 'Employee', [
|
||||||
'projects:view',
|
'projects:view',
|
||||||
'projects:create',
|
'time-entries:view:own',
|
||||||
'projects:update',
|
'time-entries:create:own',
|
||||||
'projects:delete',
|
'time-entries:update:own',
|
||||||
|
'time-entries:delete:own',
|
||||||
])->description('Editor users have the ability to read, create, and update.');
|
])->description('Editor users have the ability to read, create, and update.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "timetracking-project/timetracking",
|
"name": "solidtime-io/solidtime",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "An open-source time-tracking app",
|
"description": "An open-source time-tracking app",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "8.1.*",
|
||||||
|
"dedoc/scramble": "^0.8.5",
|
||||||
"filament/filament": "^3.2",
|
"filament/filament": "^3.2",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"inertiajs/inertia-laravel": "^0.6.8",
|
"inertiajs/inertia-laravel": "^0.6.8",
|
||||||
|
|||||||
562
composer.lock
generated
562
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -61,6 +61,8 @@ return [
|
|||||||
|
|
||||||
'asset_url' => env('ASSET_URL'),
|
'asset_url' => env('ASSET_URL'),
|
||||||
|
|
||||||
|
'force_https' => env('APP_FORCE_HTTPS', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Timezone
|
| Application Timezone
|
||||||
|
|||||||
78
config/scramble.php
Normal file
78
config/scramble.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Dedoc\Scramble\Http\Middleware\RestrictedDocsAccess;
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
* Your API path. By default, all routes starting with this path will be added to the docs.
|
||||||
|
* If you need to change this behavior, you can add your custom routes resolver using `Scramble::routes()`.
|
||||||
|
*/
|
||||||
|
'api_path' => 'api',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Your API domain. By default, app domain is used. This is also a part of the default API routes
|
||||||
|
* matcher, so when implementing your own, make sure you use this config if needed.
|
||||||
|
*/
|
||||||
|
'api_domain' => null,
|
||||||
|
|
||||||
|
'info' => [
|
||||||
|
/*
|
||||||
|
* API version.
|
||||||
|
*/
|
||||||
|
'version' => '0.0.1',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description rendered on the home page of the API documentation (`/docs/api`).
|
||||||
|
*/
|
||||||
|
'description' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Customize Stoplight Elements UI
|
||||||
|
*/
|
||||||
|
'ui' => [
|
||||||
|
/*
|
||||||
|
* Hide the `Try It` feature. Enabled by default.
|
||||||
|
*/
|
||||||
|
'hide_try_it' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* URL to an image that displays as a small square logo next to the title, above the table of contents.
|
||||||
|
*/
|
||||||
|
'logo' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use to fetch the credential policy for the Try It feature. Options are: omit, include (default), and same-origin
|
||||||
|
*/
|
||||||
|
'try_it_credentials_policy' => 'include',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The list of servers of the API. By default, when `null`, server URL will be created from
|
||||||
|
* `scramble.api_path` and `scramble.api_domain` config variables. When providing an array, you
|
||||||
|
* will need to specify the local server URL manually (if needed).
|
||||||
|
*
|
||||||
|
* Example of non-default config (final URLs are generated using Laravel `url` helper):
|
||||||
|
*
|
||||||
|
* ```php
|
||||||
|
* 'servers' => [
|
||||||
|
* 'Live' => 'api',
|
||||||
|
* 'Prod' => 'https://scramble.dedoc.co/api',
|
||||||
|
* ],
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
'servers' => [
|
||||||
|
'Production' => 'https://app.solidtime.io',
|
||||||
|
'Staging' => 'https://app.staging.solidtime.io',
|
||||||
|
'Local' => 'https://soldtime.test',
|
||||||
|
],
|
||||||
|
|
||||||
|
'middleware' => [
|
||||||
|
'web',
|
||||||
|
RestrictedDocsAccess::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'extensions' => [],
|
||||||
|
];
|
||||||
@@ -6,6 +6,7 @@ namespace Database\Factories;
|
|||||||
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
|
use App\Models\Tag;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -36,6 +37,18 @@ class TimeEntryFactory extends Factory
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withTags(Organization $organization): self
|
||||||
|
{
|
||||||
|
return $this->state(function (array $attributes) use ($organization): array {
|
||||||
|
return [
|
||||||
|
'tags' => [
|
||||||
|
Tag::factory()->forOrganization($organization)->create()->getKey(),
|
||||||
|
Tag::factory()->forOrganization($organization)->create()->getKey(),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function forUser(User $user): self
|
public function forUser(User $user): self
|
||||||
{
|
{
|
||||||
return $this->state(function (array $attributes) use ($user) {
|
return $this->state(function (array $attributes) use ($user) {
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.docker.network=${NETWORK_NAME}"
|
- "traefik.docker.network=${NETWORK_NAME}"
|
||||||
- "traefik.http.routers.timetracking.rule=Host(`${NGINX_HOST_NAME}`)"
|
- "traefik.http.routers.solidtime.rule=Host(`${NGINX_HOST_NAME}`)"
|
||||||
- "traefik.http.routers.timetracking.entrypoints=web"
|
- "traefik.http.routers.solidtime.entrypoints=web"
|
||||||
- "traefik.http.services.timetracking.loadbalancer.server.port=80"
|
- "traefik.http.services.solidtime.loadbalancer.server.port=80"
|
||||||
- "traefik.http.routers.timetracking-https.rule=Host(`${NGINX_HOST_NAME}`)"
|
- "traefik.http.routers.solidtime-https.rule=Host(`${NGINX_HOST_NAME}`)"
|
||||||
- "traefik.http.routers.timetracking-https.entrypoints=websecure"
|
- "traefik.http.routers.solidtime-https.entrypoints=websecure"
|
||||||
- "traefik.http.routers.timetracking-https.tls=true"
|
- "traefik.http.routers.solidtime-https.tls=true"
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- 'host.docker.internal:host-gateway'
|
- 'host.docker.internal:host-gateway'
|
||||||
ports:
|
ports:
|
||||||
@@ -59,9 +59,6 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
mailpit:
|
mailpit:
|
||||||
image: 'axllent/mailpit:latest'
|
image: 'axllent/mailpit:latest'
|
||||||
ports:
|
|
||||||
- '${FORWARD_MAILPIT_PORT:-1025}:1025'
|
|
||||||
- '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
|
|
||||||
networks:
|
networks:
|
||||||
- sail
|
- sail
|
||||||
playwright:
|
playwright:
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ parameters:
|
|||||||
- app/
|
- app/
|
||||||
|
|
||||||
# Level 9 is the highest level
|
# Level 9 is the highest level
|
||||||
level: 5
|
level: 7
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use App\Http\Controllers\Api\V1\ProjectController;
|
use App\Http\Controllers\Api\V1\ProjectController;
|
||||||
|
use App\Http\Controllers\Api\V1\TimeEntryController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -25,4 +27,21 @@ Route::middleware('auth:api')->prefix('v1')->name('v1.')->group(static function
|
|||||||
Route::delete('/organization/{organization}/projects/{project}', [ProjectController::class, 'destroy'])->name('destroy');
|
Route::delete('/organization/{organization}/projects/{project}', [ProjectController::class, 'destroy'])->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::name('time-entries.')->group(static function () {
|
||||||
|
Route::get('/organization/{organization}/time-entries', [TimeEntryController::class, 'index'])->name('index');
|
||||||
|
Route::post('/organization/{organization}/time-entries', [TimeEntryController::class, 'store'])->name('store');
|
||||||
|
Route::put('/organization/{organization}/time-entries/{timeEntry}', [TimeEntryController::class, 'update'])->name('update');
|
||||||
|
Route::delete('/organization/{organization}/time-entries/{timeEntry}', [TimeEntryController::class, 'destroy'])->name('destroy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fallback routes, to prevent a rendered HTML page in /api/* routes
|
||||||
|
* The / route is also included since the fallback is not triggered on the root route
|
||||||
|
*/
|
||||||
|
Route::get('/', function (): void {
|
||||||
|
throw new NotFoundHttpException('API resource not found');
|
||||||
|
});
|
||||||
|
Route::fallback(function (): void {
|
||||||
|
throw new NotFoundHttpException('API resource not found');
|
||||||
});
|
});
|
||||||
|
|||||||
35
tests/Unit/Endpoint/Api/V1/ApiEndpointTestAbstract.php
Normal file
35
tests/Unit/Endpoint/Api/V1/ApiEndpointTestAbstract.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Unit\Endpoint\Api\V1;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ApiEndpointTestAbstract extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string> $permissions
|
||||||
|
* @return object{user: User, organization: Organization}
|
||||||
|
*/
|
||||||
|
protected function createUserWithPermission(array $permissions): object
|
||||||
|
{
|
||||||
|
Jetstream::role('custom-test', 'Custom Test', $permissions)->description('Role custom for testing');
|
||||||
|
$organization = Organization::factory()->create();
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$organization->users()->attach($user, [
|
||||||
|
'role' => 'custom-test',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (object) [
|
||||||
|
'user' => $user,
|
||||||
|
'organization' => $organization,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,35 +6,10 @@ namespace Tests\Unit\Endpoint\Api\V1;
|
|||||||
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Laravel\Jetstream\Jetstream;
|
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class ProjectEndpointTest extends TestCase
|
class ProjectEndpointTest extends ApiEndpointTestAbstract
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $permissions
|
|
||||||
* @return object{user: User, organization: Organization}
|
|
||||||
*/
|
|
||||||
private function createUserWithPermission(array $permissions): object
|
|
||||||
{
|
|
||||||
Jetstream::role('custom-test', 'Custom Test', $permissions)->description('Role custom for testing');
|
|
||||||
$organization = Organization::factory()->create();
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$organization->users()->attach($user, [
|
|
||||||
'role' => 'custom-test',
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (object) [
|
|
||||||
'user' => $user,
|
|
||||||
'organization' => $organization,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_projects(): void
|
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_projects(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -67,16 +42,68 @@ class ProjectEndpointTest extends TestCase
|
|||||||
$response->assertJsonCount(4, 'data');
|
$response->assertJsonCount(4, 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_show_endpoint_fails_if_user_is_not_part_of_project_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'projects:view',
|
||||||
|
]);
|
||||||
|
$otherOrganization = Organization::factory()->create();
|
||||||
|
$project = Project::factory()->forOrganization($otherOrganization)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.projects.show', [$data->organization->getKey(), $project->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_show_endpoint_fails_if_user_has_no_permission_to_view_projects(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
]);
|
||||||
|
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.projects.show', [$data->organization->getKey(), $project->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_show_endpoint_returns_project(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'projects:view',
|
||||||
|
]);
|
||||||
|
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.projects.show', [$data->organization->getKey(), $project->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonPath('data.id', $project->getKey());
|
||||||
|
}
|
||||||
|
|
||||||
public function test_store_endpoint_fails_if_user_has_no_permission_to_create_projects(): void
|
public function test_store_endpoint_fails_if_user_has_no_permission_to_create_projects(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
$data = $this->createUserWithPermission([
|
$data = $this->createUserWithPermission([
|
||||||
]);
|
]);
|
||||||
$project = Project::factory()->forOrganization($data->organization)->make();
|
$projectFake = Project::factory()->forOrganization($data->organization)->make();
|
||||||
Passport::actingAs($data->user);
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->postJson(route('api.v1.projects.store', [$data->organization->getKey()]), $project->toArray());
|
$response = $this->postJson(route('api.v1.projects.store', [$data->organization->getKey()]), [
|
||||||
|
'name' => $projectFake->name,
|
||||||
|
'color' => $projectFake->color,
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertStatus(403);
|
$response->assertStatus(403);
|
||||||
@@ -95,7 +122,6 @@ class ProjectEndpointTest extends TestCase
|
|||||||
$response = $this->postJson(route('api.v1.projects.store', [$data->organization->getKey()]), [
|
$response = $this->postJson(route('api.v1.projects.store', [$data->organization->getKey()]), [
|
||||||
'name' => $project->name,
|
'name' => $project->name,
|
||||||
'color' => $project->color,
|
'color' => $project->color,
|
||||||
'organization_id' => $project->organization_id,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
@@ -107,6 +133,27 @@ class ProjectEndpointTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_fails_if_user_is_not_part_of_project_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'projects:update',
|
||||||
|
]);
|
||||||
|
$otherOrganization = Organization::factory()->create();
|
||||||
|
$project = Project::factory()->forOrganization($otherOrganization)->create();
|
||||||
|
$projectFake = Project::factory()->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.projects.update', [$data->organization->getKey(), $project->getKey()]), [
|
||||||
|
'name' => $projectFake->name,
|
||||||
|
'color' => $projectFake->color,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_projects(): void
|
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_projects(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -150,6 +197,23 @@ class ProjectEndpointTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_fails_if_user_is_not_part_of_project_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'projects:delete',
|
||||||
|
]);
|
||||||
|
$otherOrganization = Organization::factory()->create();
|
||||||
|
$project = Project::factory()->forOrganization($otherOrganization)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.projects.destroy', [$data->organization->getKey(), $project->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_projects(): void
|
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_projects(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -178,7 +242,7 @@ class ProjectEndpointTest extends TestCase
|
|||||||
$response = $this->deleteJson(route('api.v1.projects.destroy', [$data->organization->getKey(), $project->getKey()]));
|
$response = $this->deleteJson(route('api.v1.projects.destroy', [$data->organization->getKey(), $project->getKey()]));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(204);
|
||||||
$this->assertDatabaseMissing(Project::class, [
|
$this->assertDatabaseMissing(Project::class, [
|
||||||
'id' => $project->getKey(),
|
'id' => $project->getKey(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
478
tests/Unit/Endpoint/Api/V1/TimeEntryEndpointTest.php
Normal file
478
tests/Unit/Endpoint/Api/V1/TimeEntryEndpointTest.php
Normal file
@@ -0,0 +1,478 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Unit\Endpoint\Api\V1;
|
||||||
|
|
||||||
|
use App\Models\TimeEntry;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
|
|
||||||
|
class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||||
|
{
|
||||||
|
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_time_entries(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
]);
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_endpoint_fails_if_user_has_no_permission_to_view_time_entries_for_others_but_wants_all_entries(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:view:own',
|
||||||
|
]);
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_endpoint_returns_time_entries_for_current_user(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:view:own',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($data->user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey(), 'user_id' => $data->user->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonPath('data.0.id', $timeEntry->getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_endpoint_fails_if_user_filter_is_from_different_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:view:all',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->withPersonalOrganization()->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey(), 'user_id' => $user->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(422);
|
||||||
|
$response->assertJsonValidationErrorFor('user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_endpoint_returns_time_entries_for_other_user_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:view:all',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey(), 'user_id' => $user->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonPath('data.0.id', $timeEntry->getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_endpoint_returns_time_entries_for_all_users_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:view:all',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->getJson(route('api.v1.time-entries.index', [$data->organization->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonPath('data.0.id', $timeEntry->getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_endpoint_fails_if_user_has_no_permission_to_create_time_entries(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
]);
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->withTags($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->postJson(route('api.v1.time-entries.store', [$data->organization->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_endpoint_creates_new_time_entry_for_current_user(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:create:own',
|
||||||
|
]);
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->postJson(route('api.v1.time-entries.store', [$data->organization->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(201);
|
||||||
|
$this->assertDatabaseHas(TimeEntry::class, [
|
||||||
|
'id' => $response->json('data.id'),
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_endpoint_fails_if_user_has_no_permission_to_create_time_entries_for_others(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:create:own',
|
||||||
|
]);
|
||||||
|
$otherUser = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($otherUser, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->postJson(route('api.v1.time-entries.store', [$data->organization->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $otherUser->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_endpoint_creates_new_time_entry_for_other_user_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:create:all',
|
||||||
|
]);
|
||||||
|
$otherUser = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($otherUser, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->postJson(route('api.v1.time-entries.store', [$data->organization->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $otherUser->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(201);
|
||||||
|
$this->assertDatabaseHas(TimeEntry::class, [
|
||||||
|
'id' => $response->json('data.id'),
|
||||||
|
'user_id' => $otherUser->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_own_time_entries(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($data->user)->create();
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.time-entries.update', [$data->organization->getKey(), $timeEntry->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_fails_if_user_is_not_part_of_time_entry_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:update:own',
|
||||||
|
]);
|
||||||
|
$otherUser = $this->createUserWithPermission([
|
||||||
|
'time-entries:update:own',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($otherUser->organization)->forUser($otherUser->user)->create();
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.time-entries.update', [$data->organization->getKey(), $timeEntry->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_fails_if_user_has_no_permission_to_update_time_entries_for_other_users_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:update:own',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.time-entries.update', [$data->organization->getKey(), $timeEntry->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_updates_time_entry_for_current_user(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:update:own',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($data->user)->create();
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.time-entries.update', [$data->organization->getKey(), $timeEntry->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertDatabaseHas(TimeEntry::class, [
|
||||||
|
'id' => $timeEntry->getKey(),
|
||||||
|
'user_id' => $data->user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_updates_time_entry_of_other_user_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:update:all',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
$timeEntryFake = TimeEntry::factory()->forOrganization($data->organization)->make();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.time-entries.update', [$data->organization->getKey(), $timeEntry->getKey()]), [
|
||||||
|
'description' => $timeEntryFake->description,
|
||||||
|
'start' => $timeEntryFake->start->toIso8601String(),
|
||||||
|
'end' => $timeEntryFake->end->toIso8601String(),
|
||||||
|
'tags' => $timeEntryFake->tags,
|
||||||
|
'user_id' => $user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertDatabaseHas(TimeEntry::class, [
|
||||||
|
'id' => $timeEntry->getKey(),
|
||||||
|
'user_id' => $user->getKey(),
|
||||||
|
'task_id' => $timeEntryFake->task_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_fails_if_user_tries_to_delete_time_entry_in_organization_that_they_does_belong_to(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:all',
|
||||||
|
]);
|
||||||
|
$otherUser = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:all',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($otherUser->organization)->forUser($otherUser->user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_fails_if_user_tries_to_delete_non_existing_time_entry(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:own',
|
||||||
|
]);
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), Str::uuid()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_own_time_entries(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($data->user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_fails_if_user_has_no_permission_to_delete_time_entries_for_other_users_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:own',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_deletes_own_time_entry(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:own',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($data->user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(204);
|
||||||
|
$this->assertDatabaseMissing(TimeEntry::class, [
|
||||||
|
'id' => $timeEntry->getKey(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_destroy_endpoint_deletes_time_entry_of_other_user_in_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'time-entries:delete:all',
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$data->organization->users()->attach($user, [
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
$timeEntry = TimeEntry::factory()->forOrganization($data->organization)->forUser($user)->create();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.time-entries.destroy', [$data->organization->getKey(), $timeEntry->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(204);
|
||||||
|
$this->assertDatabaseMissing(TimeEntry::class, [
|
||||||
|
'id' => $timeEntry->getKey(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user