第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

循環(huán)遍歷包含另一個(gè)數(shù)組集合的數(shù)組

循環(huán)遍歷包含另一個(gè)數(shù)組集合的數(shù)組

PHP
牛魔王的故事 2021-10-22 12:51:46
我試圖獲取日期和課程名稱的值,但我收到了這些錯(cuò)誤異常。環(huán)形:array:2 [▼ 0 => Collection {#284 ▼#items: array:3 [▼  0 => {#277 ▼    +"date": "2018"  }  1 => {#279 ?}  4 => {#282 ?}`` ] } 1 => Collection {#283 ▼  #items: array:2 [▼   0 => {#280 ▼     +"id": 1     +"courseName": "newc1"     }  1 => {#271 ?}  ]  }  ] //tried these  @foreach ($result as $key=> $value)                    @foreach ($value as $val)                        {{$val->date}}                    @endforeach                @endforeach       //controller        $data = array();        $date = db::table('students')->select('date')->get()->unique();        $course = db::table('courses')->select('id', 'courseName')->get();        array_push($data, $date, $course);需要遍歷這些。而是得到了 ErrorException (E_ERROR) 未定義的屬性:stdClass::$date
查看完整描述

2 回答

?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

你必須控制數(shù)據(jù)庫(kù)結(jié)果,如果它在日期選擇上也可以為 laravel 使用 distinct() 和 get 必須在它之前的最后


    //This

    $date = db::table('students')->select('date')->get()->unique();

    //To This

    $date = db::table('students')->select('date')->distinct()->get();


    if(!$date)

      return $this->response;

      //or

      return false;

//更新


$course = DB::table('students')

            ->select('id','courseName', 'courses')

            ->groupBy('courses')//What ever you want to uniqe

            ->get();

對(duì)于返回視圖示例,您必須自己更改


return $this->responseWithView("index //PAGE","success", ['courses' => $course,'anything' => $youwant]);


查看完整回答
反對(duì) 回復(fù) 2021-10-22
  • 2 回答
  • 0 關(guān)注
  • 159 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)