I have this code where I want to select certain values from the table. Counter is my Model.
$today = '2022-03-16';
$tanggal = Counter::select('tanggal')->where('api', 'Agenda')->where('tanggal', $today)->get();
But if i dd($tanggal->tanggal), it returns with an error Property [tanggal] does not exist on this collection instance.
How to get a value from 'tanggal' attribute?
get()returns a collection. A collection is an array of objects. So you need to loop through that array to access individual instances. I suppose what you should be using here isfirst()instead ofget()but that is if you are expecting only one record. Otherwise, yeah. loop.