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(),
];
}
}