Last active
December 20, 2018 12:16
-
-
Save thiagomarini/90cdd27aebf43eb832781a4d56a91c7b to your computer and use it in GitHub Desktop.
Weengs Service Request Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall; | |
use Weengs\Exceptions\ValidationException; | |
use Weengs\Services\Common\BaseServiceRequest; | |
class Request extends BaseServiceRequest | |
{ | |
/** | |
* @param array $params | |
* @param array $data | |
* @throws ValidationException | |
*/ | |
public function __construct(array $params, array $data) | |
{ | |
parent::__construct($params, $data); | |
// param validation | |
$validator = $this->getValidator($params, [ | |
'user_id' => 'required|numeric' | |
]); | |
if ($validator->fails()) { | |
throw new ValidationException($validator->errors()->toArray()); | |
} | |
// data validation | |
$validator = $this->getValidator($data, [ | |
'phone' => 'required|string' | |
]); | |
if ($validator->fails()) { | |
throw new ValidationException($validator->errors()->toArray()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment