How can Filter a data from database?

In this tutorial, I’m going to learn filter a data from database. so follow this tutorial in this tutorial we have mentioned it in a very easy way.

Here is a function in which I want to see the data in which any field of the social site is filled,  If not then data is not shown in the blade page.


   public function influencerProfileDashboard()
    {
        $data = DB::table('addprofiles')
            ->leftJoin('countries', 'addprofiles.country_id', '=', 'countries.country_id')
            ->leftJoin('states', 'addprofiles.state_id', '=', 'states.state_id')
            ->leftJoin('cities', 'addprofiles.city_id', '=', 'cities.city_id')
            ->leftJoin('users', 'addprofiles.user_id', '=', 'users.id')
            ->select('addprofiles.*', 'countries.country_name', 'states.state_name', 'cities.city_name', 'users.name', 'users.email', 'addprofiles.file_pic')
            ->orderBy('id', 'desc')
            ->get();
        $filteredData = $data->filter(function ($item) {
            return !empty($item->facebook) || !empty($item->twitter) || !empty($item->youtube) || !empty($item->wordpress) || !empty($item->tumblr) || !empty($item->instagram) || !empty($item->quora) || !empty($item->pinterest) || !empty($item->reddit) || !empty($item->koo) || !empty($item->scoopit) || !empty($item->slashdot) || !empty($item->telegram) || !empty($item->fb_grp) || !empty($item->linkedin_grp) || !empty($item->linkedin) || !empty($item->roposo) || !empty($item->chingari) || !empty($item->mitron);
        });

        return view('pages.influencer', compact('filteredData'));
    }

Related Posts

How Predictive Monitoring Platforms Optimize Modern DataOps and Data Observability

Introduction Traditional monitoring systems are no longer equipped to handle this level of complexity. Legacy tools depend entirely on static thresholds, which flag problems only after a…

Read More

DataOps Integration Tools: A Guide to Seamless Data Pipeline Integration

Modern enterprise organizations generate vast quantities of information across dozens of isolated systems. Managing this distributed ecosystem requires engineering infrastructure that can ingest, process, and deliver data…

Read More

Transforming Global Healthcare Solutions with Expert Treatment Guidance

Introduction As healthcare networks expand globally, an increasing number of individuals look beyond their geographic borders for solutions. However, exploring foreign medical environments presents its own set…

Read More

Affordable Healthcare Secrets: How MyHospitalNow Helps Patients Find Verified Hospitals and Save Money

Introduction The single greatest hurdle in modern healthcare is the lack of transparent, centralized data. Comparing treatment costs across different institutions is notoriously difficult. A procedure that…

Read More

DataOps Security in Pipelines: Best Practices for Data Engineers

Data has become the primary asset of the modern enterprise, but it is also the most vulnerable. As organizations migrate from static data warehouses to distributed, real-time…

Read More

Evaluating Enterprise DataOps Tools for Secure Automation and Pipeline Orchestration

Introduction Enterprise data systems are expanding at an unprecedented rate. Organizations no longer manage just a few centralized databases. Instead, modern infrastructure spans across hybrid cloud environments,…

Read More