| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Services\Intergrations\FluentCRM; |
| 4 |
|
| 5 |
|
| 6 |
use FluentBoards\App\Models\Board; |
| 7 |
|
| 8 |
class DeepIntegration |
| 9 |
{ |
| 10 |
public function init() |
| 11 |
{ |
| 12 |
add_filter('fluentcrm_ajax_options_boards', [$this, 'getBoards'], 10, 3); |
| 13 |
} |
| 14 |
|
| 15 |
public function getBoards($records, $search, $includeIds) |
| 16 |
{ |
| 17 |
$query = Board::select(['id', 'title']); |
| 18 |
|
| 19 |
if (!empty($search)) { |
| 20 |
$query->where('title', 'like', "%$search%"); |
| 21 |
} |
| 22 |
|
| 23 |
$boards = $query->orderBy('title', 'ASC')->get(); |
| 24 |
|
| 25 |
return $this->getFormattedBoards($boards); |
| 26 |
} |
| 27 |
|
| 28 |
public function getFormattedBoards($boards) |
| 29 |
{ |
| 30 |
$formattedBoards = []; |
| 31 |
foreach ($boards as $board) { |
| 32 |
$formattedBoards[] = [ |
| 33 |
'id' => strval($board->id), |
| 34 |
'title' => $board->title |
| 35 |
]; |
| 36 |
} |
| 37 |
return $formattedBoards; |
| 38 |
} |
| 39 |
} |