php - Getting value from database column Laravel -


may simple have 1 table want take value 1 column. 2 records , 2 records , need value second id.. here visual

id     key      value  1    key_1     value_1  2    key_2     value_2 

i want take value_2. here have in controller

$free = db::table('settings')->select('value')->where('key', '=', 'free')->get();     return view::make('site.cart.order', [         'cart' => $cart,         'free' => $free     ]); 

and in view i'm trying

@if( $total < $free['value'] )     // loop @endif 

currently i'm getting - undefined index: value

if i'm right laravel returns standard class there , should access this.

$free->value 

instead of

$free['value'] 

but have change selects first record

$free = db::table('settings')->select('value')->where('key', '=', 'free')->first(); 

then can access like

$free->value 

or if don't want change get() first() can access because get() returns array.

$free[0]->value 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -