Laravel Getting attributes data

前端 未结 2 1294
孤独总比滥情好
孤独总比滥情好 2021-01-24 12:51

I am new in laravel using Laravel 5.3. I am creating a check() function in laravel model for user login here i get all data form database useing default $thi

相关标签:
2条回答
  • 2021-01-24 13:05

    So you have a collection with properties. And you can access them just like $collection->first()->firstname Or if you want to do some operation with all items use each method:

    $collection = $collection->each(function ($item, $key) {
        $item->firstname .= ' Smith';
    });
    
    0 讨论(0)
  • 2021-01-24 13:11

    A very simple way:

    $arr = $this->all()->toArray();
    
    var_dump($arr); // oh~ array data!
    
    0 讨论(0)
提交回复
热议问题