Problems in implement reCaptcha V3 in laravel - laravel

I am using Google reCaptcha v3. I am trying to implement it onto my profile page.It's load and shown in my page ,but when I want to verify it ,it does not work ,I am using this package:https://github.com/RyanDaDeng/laravel-google-recaptcha-v3#settings
in this config :
'secret_key' => env('RECAPTCHA_V3_SECRET_KEY', '6LcqC'),
'site_key' => env('RECAPTCHA_V3_SITE_KEY', '6LcqnrO-K-xb'),
in this blade :
<form>
{!! GoogleReCaptchaV3::renderOne('contact_us_id','contact_us') !!}
</form>
in my controller:
public function get_data_edit(Request $request)
{
$request->validate(
[
'phone' => ['required', 'max:11', new phone],
'year' => 'nullable|numeric',
'month' => 'nullable|numeric|max:12',
'day' => 'nullable|numeric|max:31',
'sex' => 'nullable|boolean',
'marital_status' => 'nullable|boolean',
'f_name' => 'required|max:15',
'l_name' => 'required|max:20',
'job' => 'nullable|string',
'email' => 'nullable|email',
'national_code' => 'nullable|min:10|max:10',
'family_role' => 'nullable|string',
'g-recaptcha-response' => [new GoogleReCaptchaV3ValidationRule('contact_us')]
],
[]
);
where is my problem ?

Related

Check if Stripe customer exists

I would like to check if a customer already exists so that I can update his details or if he does not exist create it by starting a new subscription.
I created this, but I believe there is something wrong.
if(Auth::user()->subscribed('default')) {
$stripe->customers->update(Auth::user()->stripe_id, array([
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]));
} else {
$stripe->customers->create([
'description' => 'Example Example',
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]);
}
I think there is a mistake, because when I go to create a new subscription with a newly registered user, therefore not present on Stripe as a customer, it does nothing but create me two entries as in the image below.
I solved it this way
$stripeCustomer = Auth::user()->createOrGetStripeCustomer([
'description' => 'Example Example',
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]);

How to reinitialize Html Builder in yajra datatable - laravel controller

I am using yjra datatable and html builder plugin. i want to show two datatable in one view. i am getting error like can not reinitialize
Controller :
public function edit($id ,Builder $builder){
$this->htmlBuilder->ajax(route('backend.ajax.my_peoples', ['project_id'=> $project->project_id,'request' => 'ajax_listing']));
$people_html = $this->htmlBuilder->columns([
['data' => 'project_person_role', 'name' => 'project_person_role', 'title' => 'Person Role'],
['data' => 'project_person_sort', 'name' => 'project_person_sort', 'title' => 'Sort'],
['data' => 'project_person_status', 'name' => 'project_person_status', 'title' => 'Status'],
['data' => 'action', 'name' => 'action', 'title' => 'Action', 'orderable' => false, 'searchable' => false, 'width' => '10%'],
]);
$this->htmlBuilder->ajax(route('backend.ajax.my_consultants', ['project_id'=> $project->project_id,'request' => 'ajax_listing']));
$dt_html = $this->htmlBuilder->columns([
['data' => 'project_consultant_role', 'name' => 'project_consultant_role', 'title' => 'Consultant Role'],
['data' => 'project_consultant_sort', 'name' => 'project_consultant_sort', 'title' => 'Sort'],
['data' => 'project_consultant_status', 'name' => 'project_consultant_status', 'title' => 'Status'],
['data' => 'action', 'name' => 'action', 'title' => 'Action', 'width' => '5%', 'orderable' => false, 'searchable' => false]
]);
return view('backend.projects.projects')->with([
'view_type' => 'edit',
'view_title' => 'Update',
'cslt_html' => $dt_html,
'people_html' => $people_html
]);
}

Why is the style different? something is missing? [duplicate]

This question already has answers here:
How do I style the HTML form validation error messages with CSS?
(4 answers)
Closed 3 years ago.
I modified the code like this: ArticleRequest.php
public function rules()
{
return [
'title' => 'required|min:2|max:255',
'slug' => 'unique:articles,slug,'.\Request::get('id'),
'content' => 'required|min:2',
'date' => 'required|date',
'status' => 'required',
'category_id' => 'required',
'description'=> 'required',
];
}
ArticleCrudController.php
$this->crud->addField([
'name' => 'description',
'label' => 'Description',
'type' => 'text',
'placeholder' => 'Description meta tag',
'attributes' => [
'required' => true,
],
]);
Why is the style different? something is missing?
thanks, you are very kind
Marco
public function rules()
{
return [
'title' => 'required|min:2|max:255',
// you should add validation rule for description attr
'description' => 'required',
'slug' => 'unique:articles,slug,'.\Request::get('id'),
'content' => 'required|min:2',
'date' => 'required|date',
'status' => 'required',
'category_id' => 'required',
'description'=> 'required',
];
}

Create method stopped working

I have this simple code
public function store(Request $request)
{
$this->Validate($request, [
'name' => 'required|min:3|max:20',
'age' => 'required|integer|between:18,99',
'height' => 'required|integer|between:120,230',
'weight' => 'required|integer|between:30,150',
'region' => 'required|integer',
'city' => 'required',
'phone' => 'required|integer'
]);
Person::create([
'name' => $request->name,
'age' => $request->age,
'height' => $request->height,
'weight' => $request->weight,
'city_id' => $request->city,
'region_id' => $request->region,
'phone' => $request->phone,
'user_id' => Auth::user()->id
]);
}
This code stop working but it doesn't show error. I have only white page. This code has worked before. And ne record doesn't create. What happend?
#edit
Now it works but... In phpmyadmin everything is ok. New records are added coccectly but tinker show my only one record which I added manually in phpmyadmin. If I try choose the lastest record added by me:
$latest = Person::where('user_id', Auth::user()->id)->latest()->first();
It show me this single element which I created in phpmyadmin. What's wrong?
Replace store as below:
public function store(Request $request) {
$this->Validate($request->all(), [
'name' => 'required|min:3|max:20',
'age' => 'required|integer|between:18,99',
'height' => 'required|integer|between:120,230',
'weight' => 'required|integer|between:30,150',
'region' => 'required|integer',
'city' => 'required',
'phone' => 'required|integer'
]);
$person= new Person();
$person->username= $request['username'];
$person->age = $request['age'];
$person->height = $request['height'];
$person->weight = $request['weight'];
$person->region = $request['region'];
$person->city = $request['city'];
$person->phone = $request['phone'];
$person->save();
}
in your controller :
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required|min:3|max:20',
'age' => 'required|integer|between:18,99',
'height' => 'required|integer|between:120,230',
'weight' => 'required|integer|between:30,150',
'region' => 'required|integer',
'city' => 'required',
'phone' => 'required|integer'
]);
Person::create([
'name' => $request->name,
'age' => $request->age,
'height' => $request->height,
'weight' => $request->weight,
'city_id' => $request->city,
'region_id' => $request->region,
'phone' => $request->phone,
'user_id' => Auth::user()->id
]);
return redirect()->back()->with('success','Person Created');
}
in your blade view :
#if (count($errors) > 0)
#foreach ($errors->all() as $error)
<p class="alert alert-danger alert-dismissible fade show" role="alert">{{ $error }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</p>
#endforeach
#endif

Symfony forms entity/document sorting the property

I'm using the symfony forms for creating a select-box with all my users.
I display them by fullname, but want to sort them alphabetically.
$builder->add('transferTo', 'document', [
'class' => 'UserBundle:User',
'property' => 'fullname',
'label' => 'Overdragen aan',
'attr' => ['class' => 'form-control selectpicker'],
'label_attr' => ['class' => 'col-sm-2 control-label'],
'multiple' => false,
'required' => true
]);
How can i sort the users alphabetically on fullname of firstName?
What you need is to add queryBuilder to the form params
use Doctrine\ORM\EntityRepository;
$builder->add('transferTo', 'document', [
'class' => 'UserBundle:User',
'query_builder' => function(EntityRepository $repository) {
return $repository->createQueryBuilder('u')->orderBy('u.fullname', 'ASC');
}
'property' => 'fullname',
'label' => 'Overdragen aan',
'attr' => ['class' => 'form-control selectpicker'],
'label_attr' => ['class' => 'col-sm-2 control-label'],
'multiple' => false,
'required' => true
]);
I assumed the fieldname in your entity is u.fullname

Resources