Jump to content

ORDER By date


raymeerwijk

Recommended Posts

I've been working on this since yesterday but i can't get this to work like i want it too.

I just want the results to order by date ascending instead of chronological order.
My knowledge is really terrible and i have tried a several number of options.

The only result is a page that keeps on loading.

This is why i would like to ask for some help.

I added an image of the things i have and the code is below

    public function getCustomerAppointments( $with_cancelled = false )
    {
        $result = array();

        if ( $this->get( 'id' ) ) {
            $appointments = CustomerAppointment::query( 'ca' )
                ->select( 'ca.*, c.name, c.phone, c.email' )
                ->leftJoin( 'Customer', 'c', 'c.id = ca.customer_id' )
                ->where( 'ca.appointment_id', $this->get( 'id' ) );
            if ( ! $with_cancelled ) {
                $appointments->whereNot( 'ca.status', Lib\Entities\CustomerAppointment::STATUS_CANCELLED );
                $appointments->whereNot( 'ca.status', Lib\Entities\CustomerAppointment::STATUS_REJECTED );
            }

            foreach ( $appointments->fetchArray() as $data ) {
                $ca = new CustomerAppointment( $data );

                // Inject Customer entity.
                $ca->customer = new Customer();
                $data['id']   = $data['customer_id'];
                $ca->customer->setFields( $data, true );

                $result[] = $ca;
            }
        }

        return $result;
    }

Hope you can help me

Ray

post-205388-0-09611800-1505587759_thumb.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.