MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/www/mpl.imenso.co/app/Typeahead/TypeaheadBuilder.php
<?php

namespace App\Typeahead;

use View;

class TypeaheadBuilder
{
    protected $search_string = '';
    protected $exclude = [];
    protected $data = [];

    public static function search($string)
    {
        $called_class = get_called_class();
        $builder = new $called_class;
        $builder->setSearchString($string);

        return $builder;
    }

    public function setSearchString($string)
    {
        $this->search_string = $string;
    }

    public function connectedOnly($connected_only)
    {
        $return = false;

        if ($connected_only == 'true') {
            $return = true;
        }

        $this->connected_only = $return;

        return $this;
    }

    public function without($exclude_array)
    {
        if (! is_array($exclude_array)) {
            $exclude_array = json_decode($exclude_array);
        }

        $this->exclude = $exclude_array;

        return $this;
    }

    public function generateHtml()
    {
        $this->html = View::make('patterns/typeahead-flyout', [
            'users' => $this->data,
        ])->render();

        return $this;
    }

    public function output()
    {
        $this->generateHtml();

        return [
            'html' => $this->html,
            'data' => $this->data->toArray(),
        ];
    }
}