Back

Return specific value of array in blade file


I am facing problem in laravel I have this data in array and want to show the data specifically with 'c_name' or others.

{ "1": [ { "c_name": "Kashimiri Lions", "t_name": "Oye Hoye Cup", "total_matches": 0, "win_matches": 0, "loss_matches": 0, "tie_matches": 0, "points_matches": 0, "rr_matches": 0 }, { "c_name": "Balochi Hawks", "t_name": "Oye Hoye Cup", "total_matches": 0, "win_matches": 0, "loss_matches": 0, "tie_matches": 0, "points_matches": 0, "rr_matches": 0 }, { "c_name": "Lahore Sultans", "t_name": "Oye Hoye Cup", "total_matches": 0, "win_matches": 0, "loss_matches": 0, "tie_matches": 0, "points_matches": 0, "rr_matches": 0 }, { "c_name": "Punjab Star", "t_name": "Oye Hoye Cup", "total_matches": 0, "win_matches": 0, "loss_matches": 0, "tie_matches": 0, "points_matches": 0, "rr_matches": 0 } ] }

Controller:

public function store(Request $request) {

    $a = [];
    $a['tournament_id'] = $request->tournament_id;
    $a['refer_id'] = $request->refer_id;
    $abc = json_encode($request->club_id);
    $a['club_id'] = $abc;
    $lastid = DB::table('tournament_clubs')->insertGetId($a);

    $input = TournamentClub::findOrFail($lastid);
    $array =  json_decode($input->club_id,true);
    $val = array();
    foreach ($array as $key=>$value)
    {
        $b=[];
        $b['tournament_id']=$request->tournament_id;
        $b['refer_id']=$request->refer_id;
        $b['club_id']=$value;
       $check =  DB::table('roundrobin_tournament')->insertGetId($b);
        $val[1] = DB::table('roundrobin_tournament')
            ->join('clubs','roundrobin_tournament.club_id','clubs.id')
            ->join('tournaments','roundrobin_tournament.tournament_id','tournaments.id')
            ->selectRaw('clubs.name AS c_name,tournaments.name AS t_name,roundrobin_tournament.total_matches,roundrobin_tournament.win_matches,roundrobin_tournament.loss_matches,roundrobin_tournament.tie_matches,roundrobin_tournament.points_matches,roundrobin_tournament.rr_matches')
            ->where('roundrobin_tournament.refer_id','=',$request->refer_id)
            ->get();
   }

Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us