What seems to be the problem:
I have a master dropdown at the top of my interface allowing me to select the client I want to work with. When changing clients, I would like a full screen refresh to occur so new data can be loaded.
Currently, I can not to as I am unable to do my redirect. I need to be able to get the route the user is currently in I have tried to access the Request and Route Classes without any success
Steps to Reproduce:
Are you using the latest version of Livewire:
yes
Do you have any screenshots or code examples:
livewire
<?php
namespace App\Http\Livewire\Admin;
use App\Models\Client;
use Livewire\Component;
use Illuminate\Support\Facades\Session;
class ClientSelector extends Component
{
public $clientsList;
public $client;
protected $rules = [
'client' => 'required|numeric',
];
//setup of the component
public function mount()
{
//loads the clients from the DB
$this->clientsList = Client::orderBy('name','asc')->pluck('name','id')->all();
//inititalises the client selected
$this->client = (!empty(Session::get('adminClientSelector'))) ? Session::get('adminClientSelector') : NULL;
}
public function updatedClient()
{
$validatedData = $this->validate();
$this->client = $validatedData['client'];
session()->put('adminClientSelector', $this->client);
NEED TO ADD REDIRECT HERE. NEEDS TO BE DYNAMIC TO GET THE CURRENT PAGE THE USER IS IN
}
public function render()
{
return view('livewire.admin.client-selector');
}
}
blade
<div class="col-xs-12 col-sm-12 col-md-12" wire:ignore>
<form wire:submit.prevent>
<div class="form-group">
<select name="client" id="client" wire:model="client" wire:submit="submit" class="form-control" >
<option value=''>Choose a client</option>
@foreach($clientsList as $key => $client)
<option value="{{ $key }}">{{ $client }}</option>
@endforeach
</select>
</div>
</form>
</div>