Components\ContactManager\Controllers\PublicController::showPublic PHP Method

showPublic() public method

Display the contact page for the specified alias
public showPublic ( $category, $alias )
$alias
    public function showPublic($category, $alias)
    {
        $form = $this->getForm(18);
        $model_name = "Components\\ContactManager\\Models\\{$form['model']}";
        $contact = $model_name::whereAlias($alias)->first();
        if (!$contact) {
            App::abort(404);
        }
        $contact->location = json_decode($contact->location, true);
        $display_options = json_decode($contact->display_options, true);
        $fields = array_combine($form['field_names'], $form['fields']);
        // Display only the fields that are set to be displayed
        $fields = array_filter($fields, function ($field) use($display_options, $contact) {
            if (isset($display_options[$field]) && $display_options[$field] == 1) {
                return true;
            } else {
                // Remove the field from the record, so that it won't be displayed
                // except for the alias
                if ($field != 'alias') {
                    unset($contact->{$field});
                    return false;
                }
            }
        });
        $this->layout->title = "Contact Page for {$contact->name}";
        $this->layout->content = View::make("public.{$this->current_theme}.contact-manager")->with('title', "Contact Page for {$contact->name}")->with('contact', $contact)->with('fields', $fields);
    }