I'm attempting to return a single column value from the first record matching my where WHERE clause. In the below example from my controller, I'm defining this result as $code. I can either get the first record or I can get a specific column value but not both.
First Record: $code = DB::table('codes')->where('redeemed', '0')->first();
Single Column Value: $code = DB::table('codes')->where('redeemed', '0')->value('code');
How can I do both in a single request?
via sparecycle