Reviews::add PHP Method

add() public method

public add ( )
    public function add()
    {
        $data['_action'] = site_url('account/reviews/add/' . $this->uri->rsegment(3) . '/' . $this->uri->rsegment(4) . '/' . $this->uri->rsegment(5));
        if ($this->Reviews_model->checkReviewed($this->uri->rsegment(3), $this->uri->rsegment(4), $this->customer->getId())) {
            $this->alert->set('danger', $this->lang->line('alert_review_duplicate'));
            redirect('account/reviews');
        }
        $this->load->model('Statuses_model');
        if ($this->uri->rsegment(3) === 'reservation') {
            $status_exists = $this->Statuses_model->statusExists('reserve', $this->uri->rsegment(4), $this->config->item('confirmed_reservation_status'));
        } else {
            $status_exists = $this->Statuses_model->statusExists('order', $this->uri->rsegment(4), $this->config->item('completed_order_status'));
        }
        if ($status_exists !== TRUE) {
            $this->alert->set('danger', $this->lang->line('alert_review_status_history'));
            redirect('account/reviews');
        }
        $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
        $this->template->setBreadcrumb($this->lang->line('text_my_account'), 'account/account');
        $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/reviews');
        $this->template->setBreadcrumb($this->lang->line('text_write_review'), 'account/reviews/add');
        $this->template->setTitle($this->lang->line('text_write_review'));
        $this->template->setHeading($this->lang->line('text_write_review'));
        $data['back_url'] = site_url('account/reviews');
        $data['customer_id'] = $this->customer->getId();
        // retriveve customer id from customer library
        $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName();
        // retrieve and concatenate customer's first and last name from customer library
        $this->load->model('Locations_model');
        $result = $this->Locations_model->getLocation($this->uri->rsegment(5));
        $data['location_id'] = $result['location_id'];
        $data['restaurant_name'] = $result['location_name'];
        //create array of ratings data to pass to view
        $ratings = $this->config->item('ratings');
        $data['ratings'] = $ratings['ratings'];
        if ($this->input->post('rating')) {
            $data['rating'] = $this->input->post('rating');
        } else {
            $data['rating'] = array('quality' => '0', 'delivery' => '0', 'service' => '0');
        }
        if ($this->input->post() and $this->_addReview() === TRUE) {
            redirect('account/reviews');
        }
        $this->template->render('account/review_add', $data);
    }