问题描述
嗨,我已经完成我在网站上拥有Google验证码所需的所有步骤。问题是我得到了这个错误
DateTime DateTime Duration Member Code
DateTime
2018-09-01 2018-09-01 2018-09-01 00:35:00 14.0 17630.0
2018-09-01 2018-09-01 2018-09-01 01:39:00 15.0 17630.0
2018-09-02 2018-09-02 2018-09-02 00:51:00 2.0 13596.0
2018-09-02 2018-09-02 2018-09-02 02:16:00 10.0 14942.0
这是我的观点
Argument 1 passed to GuzzleHttp\Client::__construct() must be of the type array,null given,called in C:\Users\userpc\Desktop\Magang\CMS\cmsglc\vendor\anhskohbo\no-captcha\src\NoCaptcha.PHP on line 50 (View: C:\Users\userpc\Desktop\Magang\CMS\cmsglc\resources\views\certificate\verify_certificate.blade.PHP)
我的控制器
@extends('layouts.header_and_footer')
@section('title','Certificate')
@section('content')
<div class="col-lg-12 text-center mt-5">
<h1>Search your certificate here</h1>
<h3>Enter your certification code or your name here</h3>
</div>
@if(session()->has('message'))
<div class="alert alert-success">
{{ session()->get('message') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
@if($errors->any())
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ implode(',',$errors->all(':message')) }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
<div class="col-md-4 offset-md-4 mt-5 ">
<div class="input-group mb-3">
<form action={{url("verify_certificate/search")}} class="site-block-top-search" method="GET" autocomplete="off">
@csrf
<div class="form-inline">
<input type="text" class="form-control" id="search" name="s_sertif" placeholder="Search">
<button type="submit" class="btn btn-primary">Search</button>
</div>
<div class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Captcha</label>
<div class="col-md-6">
{!! app('captcha')->display() !!}
@if ($errors->has('g-recaptcha-response'))
<span class="help-block">
<strong>{{ $errors->first('g-recaptcha-response') }}</strong>
</span>
@endif
</div>
</div>
</form>
</div>
</div>
@endsection
@section('javascript')
<script src='https://www.google.com/recaptcha/api.js'></script>
@endsection
我的路线
<?PHP
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Carbon\Carbon;
use DB;
use Illuminate\Support\Facades\Route;
use App\activitylog;
use Symfony\Component\Console\Input\Input;
use App\CmsItemEventCertif;
use Illuminate\Support\Facades\Validator;
class VerifyCertificateController extends Controller
{
public function display(Request $request)
{
// $test=CmsItemEventCertif::find(1);
// $test2 = $test->UserSertif;
// dd($test2);
// $la=env('APP_URL');
// dd($la);
$routes = preg_match('/([a-z]*)@([a-z]*)/i',Route::currentRouteAction(),$matches);
$routes = $matches[0];
$action = $matches[2];
DB::beginTransaction();
try {
activitylog::create([
'inserted_date'=>Carbon::Now()->TimeZone('asia/jakarta'),'username'=>"-",'application'=>$routes,'creator'=>"System",'ip_user' => $request->ip(),'action' => $action,'description'=>"display Search Certificate From Frontend",'user_agent' => $request->server('HTTP_USER_AGENT')
]);
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
return response()->json(['error' => $ex->getMessage()],500);
}
return view('certificate.verify_certificate');
}
public function search(Request $request)
{
//$search_stf = $request->s_sertif;
//dd($search_stf);
// $q = Input::get ( 's_sertif' );
DB::beginTransaction();
try {
$validator = Validator::make($request->all(),[
's_sertif' => 'required','g-recaptcha-response' => 'required|captcha',]);
if ($validator->fails()) {
$desc = 'Failed to search,field cant be empty';
// DB::beginTransaction();
return redirect('/verify_certificate')
->withErrors($desc)
->withinput();
}
// $sertif=CmsItemEventCertif::where('code','ilike','%' . $request->get('s_sertif') . '%')
// $sertif=CmsItemEventCertif::where('code','%' . $request->get('s_sertif'))
$sertif=DB::table('cms_item_event_certificate')
->join('bas_user','bas_user.id','=','cms_item_event_certificate.user_id')
->join('cms_item_event','cms_item_event.id','cms_item_event_certificate.event_id')
->where('cms_item_event_certificate.code','%' . $request->get('s_sertif'))
->orWhere('bas_user.name',$request->get('s_sertif') . '%')
// ->orWhere('bas_user.name','%' . $request->get('s_sertif'))
// ->Where('name','%' . $request->get('s_sertif'))
->select( 'cms_item_event_certificate.created_at as created_Now','cms_item_event.name as event_name','cms_item_event_certificate.code','bas_user.name','cms_item_event_certificate.title','cms_item_event_certificate.event_id','cms_item_event.photo')
->get();
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
return response()->json(['error' => $ex->getMessage()],500);
}
if(count($sertif)>0){
return view('certificate.verify_certificate_result',['sertif' => $sertif]);
}else{
$descc = 'Failed to search,record not found';
return redirect('/verify_certificate')
->withErrors($descc)
->withinput();
}
}
}
Route::get('/verify_certificate','VerifyCertificateController@display');
Route::any('/verify_certificate/search','VerifyCertificateController@search');
有什么问题吗?我已经完成了作曲家的需求,复制和粘贴相关的别名和提供程序,以及将我的网站(网址url im输入localhost,因为它仍然在本地运行,请输入btw)注册到Google Recaptcha并输入了.env的网站和密钥>
解决方法
您可以从以下2篇文章中获取帮助,以实现google recaptcha,而无需实现任何laravel软件包:
和
,我最终在下面使用了这个,谢谢您的回答,至少它使我对Google验证码表单的工作原理有了了解