Learning

How to use “where” with “pluck” in laravel?

Hello,

Here is the quick solution:

$categoryId = ProductCategory::where('id',$id)->pluck('categoryId')[0];
$parentId = ProductCategory::where('id',$id)->pluck('parentId')[0];
        
print_r($categoryId);
print_r($parentId);
        

Plucking it array index 0 as the return from pluck is array based so indexing gives us the value for the particular column you need to pluck from table.

Hope this will give you an idea or solution to your problem.

Happy Learning, Happy Learning Laravel!

admin

Recent Posts

The Ultimate Guide to Effective Meetings

In today’s fast-paced work environment, meetings are essential but can often feel unproductive. However, by…

1 week ago

From Mine to Market: How Gold Is Mined, Refined, and Sold in Shops

Gold is one of the most coveted precious metals in the world, adored for its…

1 week ago

The Historical Journey of Gold: From Ancient Civilizations to Modern Times

Gold, the shimmering metal synonymous with wealth, power, and beauty, has been deeply intertwined with…

1 week ago

How to Onboard an Intern in Small, Individual-Based Company

How to Onboard an Intern in a Small, Individual-Based Company Hiring an intern can be…

2 months ago