Reputation: 171
i am making a schedule tasking in laravel, and i need to know the value for other table and, in this case i get the properties and later i save the periods in array from a foreign key in the tables properties, later i need value from "date" in the table periods, but when i get the log i get this.
[2017-07-21 18:11:50] local.INFO: [{"id":5,"title":"Hola","date":"2017-07-25"}]
[2017-07-21 18:11:50] local.INFO: [{"id":4,"title":"dsfsd","date":"2017-07-26"}]
[2017-07-21 18:11:50] local.INFO: [{"id":4,"title":"dsfsd","date":"2017-07-26"}]
[2017-07-21 18:11:50] local.INFO: [{"id":4,"title":"dsfsd","date":"2017-07-26"}]
And i cant access to the index with $v->{"id"}, $v->id, $v["id"], i dont know if is for the way i save the information in dates, this is my function, thanks.
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$properties = DB::table( 'properties' )->where( 'status', '=', 1 )->whereNotNull( 'id_client' )->whereNotNull( 'id_period' )->get();
$dates = array();
foreach ($properties as $k => $v) {
$dates[$k] = DB::table( 'periods' )->where( 'id', '=', $v->id_period )->whereDate('date', '>', date('Y-m-d'))->get();
}
$properties_status = array();
/* ----- HERE ---------*/
foreach ($dates as $v) {
Log::info($v);
}
})->everyMinute();
}
Upvotes: 0
Views: 795
Reputation: 2904
This is JSON. It's a kind of data format. You can decode it in PHP by using:
$var = json_decode($v, true);
And in $var
you will get a normal array. Which you can simple check with print_r($var);
.
Manual
Upvotes: 1
Reputation: 163748
DB::table()->get()
returns a collection, so this will work:
Log::info($v->id);
Upvotes: 0
Reputation: 50767
You should json_decode($v)
so you can treat it like a struct. Otherwise it's just a string to you.
Upvotes: 1