vendredi 21 juillet 2017

Get Values on array from array Laravel PHP

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();
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire