Commit 337a7bb4 337a7bb47a5568a586197b138c43b144de2ac479 by lemon

*

1 parent d43bc50f
<?php
namespace App\Helper;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Log;
/**
* Class Response
* @package App\Helper
*/
class Http
{
const METHOD_POST = 'POST';
const METHOD_GET = 'GET';
/**
* @param $url
* @param array $params
* @return array|mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public static function post($uri, $params = [])
{
$url = self::formatUrl($uri);
try {
$response = (new Client())->request(self::METHOD_POST, $url, [
'json'=>$params
]);
$data = json_decode($response->getBody()->getContents(), true);
Log::info(__METHOD__, ['url'=>$url, 'params'=>$params, 'data'=>$data]);
return $data;
} catch (\Exception $e) {
Log::info(__METHOD__, ['msg'=>$e->getMessage()]);
return [];
}
}
/**
* @param $url
* @return array|mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public static function get($uri)
{
$url = self::formatUrl($uri);
try {
$response = (new Client())->request(self::METHOD_POST, $url);
$data = json_decode($response->getBody()->getContents(), true);
Log::info(__METHOD__, ['url'=>$url, 'data'=>$data]);
return $data;
} catch (\Exception $e) {
Log::info(__METHOD__, ['msg'=>$e->getMessage()]);
return [];
}
}
/**
* @param $uri
* @return string
*/
public static function formatUrl($uri)
{
return env('musician_url') . $uri;
}
}
<?php
namespace App\Http\Requests\Musician;
use Illuminate\Foundation\Http\FormRequest;
class MusicianWithdrawReceiptByNameRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'bail', 'string'],
];
}
/**
* @return string[]
*/
public function messages(): array
{
return [
'name.required' => '请提供发票单位名称',
];
}
}
<?php
return [
//提现
'wallet'=> [
'addIncome'=>'/api/wallet/addIncome', //同步数据
],
];