yesterday i found error where is my code
public function render()
{
log::info("here render data");
$socialUrls = DB::connection('payments')
->table('social_url')
->where('user_id', $this->users_id)
->get();
// Check if socialUrls is empty
$isEmpty = $socialUrls->isEmpty(); // This returns true if the collection is empty
return view('livewire.becomeinfluncer.show-socialsite', [
'socialUrls' => $socialUrls,
'isEmpty' => $isEmpty
]);
}
Solution
Issue
:The error message "Property [$users_id] not found on component: [becomeinfluncer.show-socialsite]" suggests that the property users_id is not properly initialized or accessible within your Livewire component. This could be because the property is either not declared or not assigned any value before it's used in the query. Here's how you can address this issue:
- Declare the Property: Make sure that the property users_id is declared within your Livewire component.
- Ensure Property Initialization: Ensure that users_id is set to an appropriate value before the component tries to access it in the database query .
public $users_id; // Declare the property
public function mount($users_id = null) // You can pass the user ID when mounting the component
{
// Initialize users_id, for example, from the authenticated user or passed parameter
$this->users_id = $users_id ?? auth()->id(); // Fallback to authenticated user ID if not provided
}
now i run code it works perfectly
Top comments (0)