Skip to content

Commit 4f1bd2a

Browse files
committed
added field render
1 parent 7ca6d29 commit 4f1bd2a

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="{{$id}}" class="{{$class}}" style="{{$style}}"></div>

src/Facades/GoogleReCaptchaV3.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* @method static \TimeHunter\LaravelGoogleReCaptchaV3\GoogleReCaptchaV3 setAction($value)
1111
* @method static \TimeHunter\LaravelGoogleReCaptchaV3\GoogleReCaptchaV3 setScore($value)
1212
* @method static render($mappers)
13-
* @method static renderOne($id,$action)
13+
* @method static renderOne($id, $action)
14+
* @method static renderField($id, $action, $class = '', $style = '')
1415
* @see \TimeHunter\LaravelGoogleReCaptchaV3\GoogleReCaptchaV3
1516
*/
1617
class GoogleReCaptchaV3 extends Facade

src/GoogleReCaptchaV3.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class GoogleReCaptchaV3
1616
{
1717
private $service;
1818
private $defaultTemplate = 'GoogleReCaptchaV3::googlerecaptchav3.template';
19+
private $defaultFieldTemplate = 'GoogleReCaptchaV3::googlerecaptchav3.field';
1920

2021
public static $hasAction = false;
2122

@@ -75,7 +76,7 @@ public function prepareBackgroundViewData()
7576
*/
7677
public function init()
7778
{
78-
if (! $this->getConfig()->isServiceEnabled()) {
79+
if (!$this->getConfig()->isServiceEnabled()) {
7980
return;
8081
}
8182
$default = [
@@ -96,6 +97,22 @@ public function renderOne($id, $action)
9697
self::$collection[$id] = $action;
9798
}
9899

100+
101+
/**
102+
* @param $id
103+
* @param $action
104+
* @param $class
105+
* @param string $style
106+
* @return \Illuminate\Contracts\View\View|mixed
107+
*/
108+
public function renderField($id, $action, $class,$style = '')
109+
{
110+
self::$hasAction = true;
111+
self::$collection[$id] = $action;
112+
return app('view')->make($this->getFieldView(), ['id' => $id, 'class'=>$class, 'style' => $style]);
113+
}
114+
115+
99116
/**
100117
* @param $mappers
101118
*/
@@ -115,6 +132,15 @@ protected function getView()
115132
return $this->defaultTemplate;
116133
}
117134

135+
136+
/**
137+
* @return mixed|string
138+
*/
139+
protected function getFieldView()
140+
{
141+
return $this->defaultFieldTemplate;
142+
}
143+
118144
/**
119145
* @param $response
120146
* @param null $ip

0 commit comments

Comments
 (0)