从模型中检索时,Laravel显示“string()”

时间:2014-09-24 15:59:47

标签: php laravel

在laravel中,我执行以下查询:

$courses = Curs::where('gruppe', "=", "fredag-wills")->get();

当我运行$courses->gruppe时,它会返回字符串(12)“fredag​​-wills”而不是 fredag​​-wills 为什么?

这是var_dump($courses);结果

   object(Illuminate\Database\Eloquent\Collection)#244 (1) {
  ["items":protected]=>
  array(15) {
      ["attributes":protected]=>
      array(12) {
        ["id"]=>
        string(2) "48"
        ["keyid"]=>
        string(33) "wills-fredag-1-souvkimjmvpqdwsckh"
        ["endtime"]=>
        string(8) "12:50:00"
        ["parallel"]=>
        string(1) "0"
        ["gruppe"]=>
        string(12) "fredag-wills"
        ["booked"]=>
        string(1) "0"
      }

1 个答案:

答案 0 :(得分:0)

这些字符串只是由var_dump绘制的,所以你可以看到每个变量类型,如果你不想在调试时看到它们,你可以这样做:

$courses = Curs::where('gruppe', "=", "fredag-wills")->get();

foreach($courses as $course)
{
   echo $course->keyid . '<br>';
}

die;