30
loading...
This website collects cookies to deliver better user experience
@if( !request()->routeIs('charters.show') && !request()->routeIs('pages.message-us') )
<livewire:support-message />
@endif
support-message.blade.php
file is a basic form with a conditional to show the form. Ah what the heck I'll put it here. Here you go:<div>
@if(!$show_form)
<div wire:click="displayForm()" class="fixed bottom-14 right-2 md:bottom-0 py-1 px-4 rounded-tl-lg rounded-tr-lg bg-yellow-500 hover:bg-yellow-600 flex items-center cursor-pointer z-50">
<i class="fal fa-envelope text-white text-xl font-bold mr-3"></i><span class="text-base font-bold text-white">Leave a Message</span>
</div>
@else
<div class="fixed bottom-14 right-2 md:bottom-0 shadow-lg z-50 max-h-96 overflow-scroll">
<div class="bg-yellow-500 flex items-center justify-between py-2 pl-4 pr-2 rounded-tl-lg rounded-tr-lg">
<span class="text-white text-base">FishAnywhere Support</span>
<span class="text-white text-xl mr-2 font-bold cursor-pointer" wire:click="displayForm()"><i class="fal fa-times"></i></span>
</div>
<div class="flex flex-col bg-gray-200 px-4">
<div class="my-1">@include('partials._text-field-input', ['model' => 'name', 'label' => 'Name *'])</div>
<div class="my-1">@include('partials._text-field-input', ['model' => 'email', 'label' => 'Email *'])</div>
<div class="my-1">@include('partials._text-field-input', ['model' => 'phone_number', 'label' => 'Phone Number *'])</div>
<div class="my-1">@include('partials._text-area-input', ['model' => 'comments', 'label' => 'Comments *'])</div>
<div class="my-1 pb-4"><button wire:click="save()" class="text-white bg-yellow-500 hover:bg-yellow-600 rounded-lg py-1 px-4">Submit</button></div>
</div>
</div>
@endif
</div>
route()
, request()
,url()
, and logger()
are a few that I use the most. I use these in blade directives / controllers, you name it. Normally to get the current route I would do something like: request()->route()->getName()
and if all of your routes are using the named route modifier it will grab it. If you want the current url you can use url()->current()
. So in our route files every single route are named, that being said the Admins whom are going to see these submissions, well even as intuitive as are named routes are, I am not 100% sure they would be able to decipher them all. So initially I threw:$meta = [ 'url' => url()->current() ];
$submission->meta = $meta
. Obviously none of this will happen unless the inputs are validated. After my first submission the Url displayed in the slack / email was http://127.0.0.1:8000/livewire/message/support-message
, and I submitted the message on the home page. I'm not really sure why this is happening, I can only assume that it has something to do with livewires routing under the hood, and as I explained before I'm not gonna try to understand the genius of Caleb and I'm just going to have to figure a work around. <livewire:support-message url="{{ url()->current() }}"/>
public function mount(string $url)
{
$this->url = $url;
}
url()
method. Why? Again, no idea and don't need to dig into the heart of livewire. So this simplifies it quite a bit and now I get:<livewire:support-message />
public function mount()
{
$this->url = url()->current();
}