1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Erro Collection Laravel 5.6

Discussion in 'Technology' started by Ronaldo Adriano, Oct 8, 2018.

  1. Caros,

    Podem me auxiliar com este erro:

    [​IMG]

    Erro é dado na arquivo abaixo, quando imprimo a variável $referencia ela vem no formato correto de data '20181008'.

    Collection

    /** @var \Illuminate\Support\Collection */
    protected $dias; //Protege dias


    public static function trataDados( Carbon $referencia, $items = [], $flag_negocio )
    {
    $collection = new ClusterCollection( $items );
    $collection->setReferencia( $referencia );
    dd($referencia);
    return new Fluent( [
    'dias' => $collection->dias->map( function ( Carbon $dia ) {
    return $dia->format( 'd/M | D' );
    } ),
    'dados' => $collection->normalizaDados( $flag_negocio ),
    ] );
    }

    protected function setReferencia( Carbon $referencia )
    {
    $referencia = $referencia
    ? $referencia->copy()->startOfMonth()
    : now()->startOfMonth();

    $referencia = Date::createFromTimestamp( $referencia->timestamp );

    $fimDoMes = $referencia->copy()->endOfMonth();

    $this->dias = collect();

    while ($referencia->lt( $fimDoMes )) {
    $this->dias->push( $referencia->copy()->startOfDay() );
    $referencia->addDay();
    }
    }


    Controller

    public function index(Request $request, $dia, $flag_negocio = 'Novos Negócios')
    {
    $flag_negocio = $flag_negocio == 'NULL' ? null : $flag_negocio;

    $date = Date("Y-m-d");

    $datas = collect(range(0, 90))
    ->map(function ($incremento) {
    return now_tz()->subDays($incremento);
    });

    ///**Tabela Pagamento por Cluster**/// OK
    $clusters = Pagamentos::makeCluster($date->format('Ymd'), $flag_negocio)
    ->orderBy('RAZAO_CLI')
    ->get();

    $dados = ClusterCollection::trataDados($date, $clusters, $flag_negocio );


    return view('pagamentos.cnc.operacional.index',
    compact('flag_negocio', 'datas','clusters','dados'));
    }


    Model

    public static function makeCluster($date, $flag_negocio)
    {

    /** @var static $instance */
    $instance = new static;

    $table = sprintf('QLIKVIEW.dbo.FN_QLIKVIEW_PAGAMENTOS_DASHBOARD_CLUSTER_CNC(\'%s\',\'%s\')',
    $date,
    $flag_negocio
    );

    return $instance->setTable($table);
    }

    Login To add answer/comment
     

Share This Page