Skip to content

Instantly share code, notes, and snippets.

@javedbaloch4
Created September 4, 2020 14:24
Show Gist options
  • Save javedbaloch4/48e60bf4f1ca7ca4a6cb6adec521f175 to your computer and use it in GitHub Desktop.
Save javedbaloch4/48e60bf4f1ca7ca4a6cb6adec521f175 to your computer and use it in GitHub Desktop.
Livewire Form Icons missing.
<!-- ContactUs Component -->
<?php
namespace App\Http\Livewire\Front;
use App\Rules\Captcha;
use Livewire\Component;
class ContactUs extends Component
{
public $fullName;
public $email;
public $phone;
public $message;
public $reCaptchaResponse;
public function submit() {
// Validate the form
$this->validate([
'fullName' => 'required',
'email' => 'required|email',
'phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
'message' => 'required|max:500',
'reCaptchaResponse' => new Captcha()
]);
// Store In DB
\App\ContactUs::create([
'fullName' => $this->fullName,
'email' => $this->email,
'phone' => $this->phone,
'message' => $this->message,
]);
// Session Message
session()->flash('message', 'Thank you for getting in touch! We appreciate you contacting us');
// Clear the form
$this->fullName = $this->email = $this->phone = $this->message = "";
}
// Form Submitted
public function click() {
// On Click Submit
}
public function render()
{
return view('livewire.front.contact-us');
}
}
// Blade File
<div>
<div >
@if(session()->has('message'))
<div class="alert alert-success">
<i data-feather="user" class="fea icon-sm icons"></i>{{ session('message') }}
</div>
@endif
<form wire:submit.prevent="submit" method="post">
<div class="row">
<div class="col-md-12">
<div class="form-group position-relative">
<label>Full Name <span class="text-danger">*</span></label>
<i data-feather="user" class="fea icon-sm icons"></i>
<input type="text" class="form-control pl-5"
placeholder="Full Name :" wire:model.lazy="fullName">
@error('fullName')
<strong class="text-danger">{{ $message }}</strong>
@enderror
</div>
</div><!--end col-->
<div class="col-md-12">
<div class="form-group position-relative">
<label>Your Email <span class="text-danger">*</span></label>
<i data-feather="mail" class="fea icon-sm icons"></i>
<input wire:model.lazy="email" class="form-control pl-5"
placeholder="Your email :">
@error('email')
<strong class="text-danger">{{ $message }}</strong>
@enderror
</div>
</div><!--end col-->
<div class="col-md-12">
<div class="form-group position-relative">
<label>Phone <span class="text-danger">*</span></label>
<i data-feather="smartphone" class="fea icon-sm icons"></i>
<input wire:model.lazy="phone" class="form-control pl-5"
placeholder="Your Phone :">
@error('phone')
<strong class="text-danger">{{ $message }}</strong>
@enderror
</div>
</div><!--end col-->
<div class="col-md-12">
<div class="form-group position-relative">
<label>Message</label>
<i data-feather="message-circle" class="fea icon-sm icons"></i>
<textarea wire:model.lazy="message" rows="4"
class="form-control pl-5"
placeholder="Your Message :"></textarea>
@error('message')
<strong class="text-danger">{{ $message }}</strong>
@enderror
</div>
</div>
<div class="col-md-12">
<div class="form-group position-relative">
<div class="col-md-12">
<div class="form-group">
<div class="g-recaptcha" data-sitekey="{{ env('CAPTCHA_KEY') }}" wire:ignore></div>
@if($errors->has('reCaptchaResponse'))
<span class="invalid-feedback" style="display:block">
<strong>{{ $errors->first('reCaptchaResponse') }}</strong>
</span>
@endif
</div>
</div>
</div>
</div>
</div><!--end row-->
<div class="row">
<div class="col-sm-12 text-center">
<button type="submit" wire:click="click" class="submitBnt btn btn-primary btn-block">
Send Message
<span wire:loading wire:target="click">
<div class="spinner-border text-light spinner-border-sm" role="status">
<span class="sr-only">Loading...</span>
</div>
</span>
</button>
</div><!--end col-->
</div><!--end row-->
</form><!--end form-->
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment