Error Call to a member function where() on array Laravel

Published

I want to do filtering from the data that I display, but there is a problem when I add where to my data.

the plan in the future I want to add if isset $request name, date and others. but was constrained at this one point.

Thank you for helping to answer in advance

    $matchs =Matchs::where('type', 'sparring')->where('status','Pending')->whereNull('deleted_at')->get()->toArray();
    $data=[];
    foreach ($matchs as $key) {
        $lawan = Matchs::where('id', $key['id'])->first()->ToArray();
        $pertandingan = Sparring::where('match_id', $key['id'])->first()->ToArray();
        $dua_arah = MatchTwoTeam::where('match_id', $key['id'])->first()->ToArray();
        $tim =  Team::where('id', $dua_arah['home_team'])->first()->ToArray();


                $transfer['name']=$tim['name'];
                $transfer['city']=$lawan['city'];
                $transfer['field_cost']=$pertandingan['field_cost'];
                $transfer['referee_cost']=$pertandingan['referee_cost'];
                $transfer['logo_path']=$tim['logo_path'];
                $transfer['nama_lapangan']=$lawan['nama_lapangan'];
                $transfer['date']=$lawan['date'];
                array_push($data,$transfer);  
        array_push($data,$pertandingan);  
    
    }
    $data->where('name', 'LIKE', '%'.'football'.'%')->get()->toArray();
    $data = array_search('football', array_column($data, 'name'));
    $tittle="Sparring";
    return view('mode.sparring',[
        'tittle' => $tittle,
        'data' => $data,
    ]);

Source: Laravel

Published
Categorised as eloquent, laravel Tagged ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq