Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120822722
ReferralCode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
ReferralCode.php
View Options
<?php
namespace
App\Rules
;
use
Illuminate\Contracts\Validation\Rule
;
class
ReferralCode
implements
Rule
{
private
$message
;
/**
* Determine if the validation rule passes.
*
* @param string $attribute Attribute name
* @param mixed $code Referral code
*/
public
function
passes
(
$attribute
,
$code
):
bool
{
// Check the max length, according to the database column length
if
(!
is_string
(
$code
)
||
strlen
(
$code
)
>
16
)
{
$this
->
message
=
\trans
(
'validation.referralcodeinvalid'
);
return
false
;
}
$exists
=
\App\ReferralCode
::
where
(
'code'
,
$code
)
->
join
(
'referral_programs'
,
'referral_programs.id'
,
'='
,
'referral_codes.program_id'
)
->
withEnvTenantContext
()
->
where
(
'active'
,
true
)
->
exists
();
if
(!
$exists
)
{
$this
->
message
=
\trans
(
'validation.referralcodeinvalid'
);
return
false
;
}
return
true
;
}
/**
* Get the validation error message.
*/
public
function
message
():
?
string
{
return
$this
->
message
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 9:54 AM (1 w, 3 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9f/f3/7b3793b42fdf0237f2eef988db9f
Default Alt Text
ReferralCode.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline