2016-11-04 70 views
0

我写了这个查询得到字符串type(value),这是向上或向下,而是它返回一个对象。laravel查询retun对象而不是字符串

$o_response = $this->statuses() 
    ->where('status_id', $o_health_status->id) 
    ->orderBy('created_at', 'desc') 
    ->select('values') 
    ->first(); 

这是结果:

{"values":"up","pivot":{"notification_id":1,"status_id":1,"values":"up","created_at":"2016-11-04 13:18:29","updated_at":"2016-11-04 13:18:29"}} 

它返回一个对象,而不是字符串。为什么?

+0

我期待得到一个字符串vsalue,它是向上或向下,而不是我获得整个对象。我应该改变什么? –

回答

-1

Laravel雄辩地返回集合ex .-> get()或object ex。 - > first()。

所以我认为你需要只是为了获得柱像

$ o_response = $ o_response->值;

+0

我想欣赏快速和完美的重播。这个对我有用。 TNX –

相关问题