Skip to content

Instantly share code, notes, and snippets.

@thiagomarini
Last active December 20, 2018 12:16
Show Gist options
  • Save thiagomarini/90cdd27aebf43eb832781a4d56a91c7b to your computer and use it in GitHub Desktop.
Save thiagomarini/90cdd27aebf43eb832781a4d56a91c7b to your computer and use it in GitHub Desktop.
Weengs Service Request Example
<?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