Snipe-IT
Open Source Asset Management
FEATURES
DEMO
DOWNLOAD
DOCUMENTATION
HOSTED SOLUTION
SUPPORT
Intro
Namespaces
Classes
Files
Misc
snipe-it
app
Providers
AppServiceProvider.php
Go to the documentation of this file.
1
<?php
2
namespace
App\Providers
;
3
4
use
Validator
;
5
use
Illuminate\Support\ServiceProvider
;
6
14
class
AppServiceProvider
extends
ServiceProvider
15
{
23
public
function
boot
()
24
{
25
26
// Email array validator
27
Validator::extend(
'email_array'
,
function
($attribute, $value, $parameters, $validator) {
28
$value = str_replace(
' '
,
''
,$value);
29
$array = explode(
','
, $value);
30
31
foreach
($array as $email)
//loop over values
32
{
33
$email_to_validate[
'alert_email'
][]=$email;
34
}
35
36
$rules = array(
'alert_email.*'
=>
'email'
);
37
$messages = array(
38
'alert_email.*'
=>trans(
'validation.email_array'
)
39
);
40
41
$validator = Validator::make($email_to_validate,$rules,$messages);
42
43
if
($validator->passes()) {
44
return
true
;
45
}
else
{
46
return
false
;
47
}
48
49
});
50
}
51
57
public
function
register
()
58
{
59
//
60
}
61
}
App\Providers
Definition:
AppServiceProvider.php:2
App\Providers\AppServiceProvider
This service provider handles a few custom validation rules.
Definition:
AppServiceProvider.php:14
Validator
App\Providers\AppServiceProvider\boot
boot()
Custom email array validation.
Definition:
AppServiceProvider.php:23
ServiceProvider