mercredi 28 mars 2018

How to exclude private events in laravel 5.5?

I have this piece of legacy code to return all events to the front end:

/**
     * @param $request
     *
     * @return mixed
     */
    public function index( EventsFilterRequest $request ) {
        $keys = $request->all();

        if ( \count( $keys ) === 0 ) {
            return $this->eventsQueryBuilder()->isVisibleFor( authUser()->id )->ofOrder( 'starts_at', 'ASC' )->ofCountry( runtime()->country()->id )->ofStatus( 'future' );
        }

        $events = $this->eventsQueryBuilder()->isVisibleFor( authUser()->id )->ofOrder( 'starts_at', 'ASC' )->ofStatus( 'future' )->ofCountry( runtime()->country()->id );
        foreach ( $keys as $key => $value ) {
            if ( array_key_exists( $key, $this->_methods ) ) {
                $events = $this->_methods[$key]( $events, $request, $this );
            }
        }

        return $events;
    }

In the events table there's a column called privacy that contains public or private. How can I exclude private events from being returned ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uomeEw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire