app/Console/Commands/UpdateClassified.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle(){
        $time_now = time();
        $classified_vip = ClassifiedVip::select('clv_cla_id','clv_id')->where('clv_date','<',$time_now)->where('clv_type_vip',1)->get();
        $arr_cla_id = $classified_vip->map(function($item){return $item->clv_cla_id;})->toArray();
        if(count($arr_cla_id)==0){
            $this->info('No id');
            return true;
        }
        $this->info('ID:'.implode(',',$arr_cla_id));
        Classified::whereIn('cla_id',$arr_cla_id)->update(['cla_date'=>$time_now]);
        $arr_clv_id = $classified_vip->map(function($item){return $item->clv_id;});
        ClassifiedVip::whereIn('clv_id',$arr_clv_id)->delete();
        $classified_controller = new ClassifiedController();
        foreach ($arr_cla_id as $id){
            $classified_controller->syncData($id,['cla_date'=>$time_now]);
        }
    }
public function handle ( ) { $ time_now = time ( ) ; $ classified_vip = ClassifiedVip :: select ( 'clv_cla_id' , 'clv_id' ) -> where ( 'clv_date' , '<' , $ time_now ) -> where ( 'clv_type_vip' , 1 ) -> get ( ) ; $ arr_cla_id = $ classified_vip -> map ( function ( $ item ) { return $ item -> clv_cla_id ; } ) -> toArray ( ) ; if ( count ( $ arr_cla_id ) == 0 ) { $ this -> info ( 'No id' ) ; return true ; } $ this -> info ( 'ID:' . implode ( ',' , $ arr_cla_id ) ) ; Classified :: whereIn ( 'cla_id' , $ arr_cla_id ) -> update ( [ 'cla_date' => $ time_now ] ) ; $ arr_clv_id = $ classified_vip -> map ( function ( $ item ) { return $ item -> clv_id ; } ) ; ClassifiedVip :: whereIn ( 'clv_id' , $ arr_clv_id ) -> delete ( ) ; $ classified_controller = new ClassifiedController ( ) ; foreach ( $ arr_cla_id as $ id ) { $ classified_controller -> syncData ( $ id , [ 'cla_date' => $ time_now ] ) ; } }
Execute the console command.
Execute the console command .