laravel-learn-bbs/app/Http/Requests/Api/SocialAuthorizationRequest.php

28 lines
617 B
PHP
Raw Normal View History

2018-06-03 13:09:33 +00:00
<?php
namespace App\Http\Requests\Api;
class SocialAuthorizationRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'code' => 'required_without:access_token|string',
'access_token' => 'required_without:code|string',
'openid' => 'required_with:access_token|string'
];
if ($this->get('social_type') == 'weixin' && !$this->get('code')) {
$rules['openid'] = 'required|string';
}
return $rules;
}
}