| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Cortex\Contacts\DataTables\Adminarea; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Cortex\Contacts\Models\Contact; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Database\Eloquent\Builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Cortex\Foundation\DataTables\AbstractDataTable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Cortex\Contacts\Transformers\Adminarea\ContactTransformer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class ContactsDataTable extends AbstractDataTable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     protected $model = Contact::class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     protected $transformer = ContactTransformer::class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * Display ajax response. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public function ajax() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         return datatables($this->query()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             ->setTransformer(app($this->transformer)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ->filterColumn('country_code', function (Builder $builder, $keyword) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |                 $countryCode = collect(countries())->search(function ($country) use ($keyword) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |                     return mb_strpos($country['name'], $keyword) !== false || mb_strpos($country['emoji'], $keyword) !== false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |                 }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 ! $countryCode || $builder->where('country_code', $countryCode); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             ->filterColumn('language_code', function (Builder $builder, $keyword) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |                 $languageCode = collect(languages())->search(function ($language) use ($keyword) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                     return mb_strpos($language['name'], $keyword) !== false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                 }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                 ! $languageCode || $builder->where('language_code', $languageCode); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             ->make(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * Get columns. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |     protected function getColumns(): array | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |         $link = config('cortex.foundation.route.locale_prefix') | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |             ? '"<a href=\""+routes.route(\'adminarea.contacts.edit\', {contact: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"' | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |             : '"<a href=\""+routes.route(\'adminarea.contacts.edit\', {contact: full.id})+"\">"+data+"</a>"'; | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |         return [ | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |             'given_name' => ['title' => trans('cortex/contacts::common.given_name'), 'render' => $link, 'responsivePriority' => 0], | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |             'family_name' => ['title' => trans('cortex/contacts::common.family_name')], | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |             'email' => ['title' => trans('cortex/contacts::common.email')], | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |             'phone' => ['title' => trans('cortex/contacts::common.phone')], | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |             'country_code' => ['title' => trans('cortex/contacts::common.country'), 'render' => 'full.country_emoji+" "+data'], | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |             'language_code' => ['title' => trans('cortex/contacts::common.language'), 'visible' => false], | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |             'created_at' => ['title' => trans('cortex/contacts::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |             'updated_at' => ['title' => trans('cortex/contacts::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |         ]; | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |  | 
            
                        
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: