1. Go to this page and download the library: Download vildanbina/livewire-tabs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vildanbina / livewire-tabs example snippets
namespace App\Http\Livewire;
use Vildanbina\LivewireTabs\TabsComponent;
use App\Models\User;
class UserTab extends TabsComponent
{
// My custom class property
public $userId;
/*
* Will return App\Models\User instance or will create empty User (based on $userId parameter)
*/
public function model()
{
return User::findOrNew($this->userId);
}
}
$tabsFormInstance->getCurrentTab();
$tabsFormInstance->setTab($tab);
public function tabFooter()
{
return view('livewire-tabs::tabs-footer');
}
namespace App\Tabs;
use Vildanbina\LivewireTabs\Components\Tab;
use Illuminate\Validation\Rule;
class General extends Tab
{
// Tab view located at resources/views/tabs/general.blade.php
protected string $view = 'tabs.general';
/*
* Initialize tab fields
*/
public function mount()
{
$this->mergeState([
'name' => $this->model->name,
'email' => $this->model->email,
]);
}
/*
* Tab icon
*/
public function icon()
{
return view('icons.home');
}
/*
* When Tabs Form has submitted
*/
public function save($state)
{
$user = $this->model;
$user->name = $state['name'];
$user->email = $state['email'];
$user->save();
}
/*
* Tab Validation
*/
public function validate()
{
return [
[
'state.name' => ['
use Vildanbina\LivewireTabs\Components\Tab;
class General extends Tab
{
public function onTabIn($newTab)
{
// Something you want
}
public function onTabOut($oldTab)
{
// Something you want
}
public function updating($name, $value)
{
// Something you want
}
public function updatingState($name, $value)
{
// Something you want
}
public function updated($name, $value)
{
// Something you want
}
public function updatedState($name, $value)
{
// Something you want
}
}
namespace App\Http\Livewire;
use App\Tabs\General;
use Vildanbina\LivewireTabs\TabsComponent;
class UserTab extends TabsComponent
{
public array $tabs = [
General::class,
// Other tabs...
];
...
}