Pretty basic stuff, but really new to LW. So apologies for the noob question.
I can’t figure out how to pass data to my show page.
I have a plans page that is pulling 3 plans from the DB.
When I click on Plan 1 I want to show that info by using the data from the DB.
Here is my setup.
Routes:
Route::livewire('/subscription', 'subscription.plans')->name('subscription-plans');
Route::livewire('/subscription/checkout', 'subscription.plans-checkout')->name('subscription-plans-checkout');
Plans Controller:
use App\Plan;
use Livewire\Component;
class Plans extends Component
public function render()
{
$plans = Plan::get();
return view('livewire.subscription.plans', compact('plans'));
}
Plan Show Controller:
This is currently working because I’m Hardcoding in the plan ID.
use App\Plan;
use Illuminate\Support\Facades\Session;
use Livewire\Component;
class PlansCheckout extends Component
...
public $plan, $plan_id, $title, $price, $slug;
public function mount(Plan $plan)
{
$plan = Plan::find(1); // HARDCODED ID
$this->plan = $plan;
$this->plan_id = $plan->id;
$this->title = $plan->title;
$this->price = $plan->price;
$this->slug = $plan->slug;
}
public function render()
{
return view('livewire.subscription.plans-checkout');
}
How can I get the plan ID dynamically?
Any help would be appreciated.
Thank,
Chris