Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Column often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Column, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 44 | class Column |
||
| 45 | { |
||
| 46 | use Column\HasHeader; |
||
| 47 | |||
| 48 | const SELECT_COLUMN_NAME = '__row_selector__'; |
||
| 49 | |||
| 50 | const ACTION_COLUMN_NAME = '__actions__'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var Grid |
||
| 54 | */ |
||
| 55 | protected $grid; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Name of column. |
||
| 59 | * |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | protected $name; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Label of column. |
||
| 66 | * |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | protected $label; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Original value of column. |
||
| 73 | * |
||
| 74 | * @var mixed |
||
| 75 | */ |
||
| 76 | protected $original; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Attributes of column. |
||
| 80 | * |
||
| 81 | * @var array |
||
| 82 | */ |
||
| 83 | protected $attributes = []; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Relation name. |
||
| 87 | * |
||
| 88 | * @var bool |
||
| 89 | */ |
||
| 90 | protected $relation = false; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Relation column. |
||
| 94 | * |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | protected $relationColumn; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Original grid data. |
||
| 101 | * |
||
| 102 | * @var Collection |
||
| 103 | */ |
||
| 104 | protected static $originalGridModels; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var []Closure |
||
| 108 | */ |
||
| 109 | protected $displayCallbacks = []; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Displayers for grid column. |
||
| 113 | * |
||
| 114 | * @var array |
||
| 115 | */ |
||
| 116 | public static $displayers = [ |
||
| 117 | 'editable' => Displayers\Editable::class, |
||
| 118 | 'switch' => Displayers\SwitchDisplay::class, |
||
| 119 | 'switchGroup' => Displayers\SwitchGroup::class, |
||
| 120 | 'select' => Displayers\Select::class, |
||
| 121 | 'image' => Displayers\Image::class, |
||
| 122 | 'label' => Displayers\Label::class, |
||
| 123 | 'button' => Displayers\Button::class, |
||
| 124 | 'link' => Displayers\Link::class, |
||
| 125 | 'badge' => Displayers\Badge::class, |
||
| 126 | 'progressBar' => Displayers\ProgressBar::class, |
||
| 127 | 'progress' => Displayers\ProgressBar::class, |
||
| 128 | 'radio' => Displayers\Radio::class, |
||
| 129 | 'checkbox' => Displayers\Checkbox::class, |
||
| 130 | 'orderable' => Displayers\Orderable::class, |
||
| 131 | 'table' => Displayers\Table::class, |
||
| 132 | 'expand' => Displayers\Expand::class, |
||
| 133 | 'modal' => Displayers\Modal::class, |
||
| 134 | 'carousel' => Displayers\Carousel::class, |
||
| 135 | 'downloadable' => Displayers\Downloadable::class, |
||
| 136 | 'copyable' => Displayers\Copyable::class, |
||
| 137 | 'qrcode' => Displayers\QRCode::class, |
||
| 138 | 'prefix' => Displayers\Prefix::class, |
||
| 139 | 'suffix' => Displayers\Suffix::class, |
||
| 140 | 'secret' => Displayers\Secret::class, |
||
| 141 | 'limit' => Displayers\Limit::class, |
||
| 142 | ]; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Defined columns. |
||
| 146 | * |
||
| 147 | * @var array |
||
| 148 | */ |
||
| 149 | public static $defined = []; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @var array |
||
| 153 | */ |
||
| 154 | protected static $htmlAttributes = []; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @var array |
||
| 158 | */ |
||
| 159 | protected static $rowAttributes = []; |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @var Model |
||
| 163 | */ |
||
| 164 | protected static $model; |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @var bool |
||
| 168 | */ |
||
| 169 | protected $searchable = false; |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @param string $name |
||
| 173 | * @param string $label |
||
| 174 | */ |
||
| 175 | public function __construct($name, $label) |
||
| 176 | { |
||
| 177 | $this->name = $name; |
||
| 178 | |||
| 179 | $this->label = $this->formatLabel($label); |
||
| 180 | |||
| 181 | $this->initAttributes(); |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Initialize column attributes. |
||
| 186 | */ |
||
| 187 | protected function initAttributes() |
||
| 188 | { |
||
| 189 | $name = str_replace('.', '-', $this->name); |
||
| 190 | |||
| 191 | $this->setAttributes(['class' => "column-{$name}"]); |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Extend column displayer. |
||
| 196 | * |
||
| 197 | * @param $name |
||
| 198 | * @param $displayer |
||
| 199 | */ |
||
| 200 | public static function extend($name, $displayer) |
||
| 201 | { |
||
| 202 | static::$displayers[$name] = $displayer; |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Define a column globally. |
||
| 207 | * |
||
| 208 | * @param string $name |
||
| 209 | * @param mixed $definition |
||
| 210 | */ |
||
| 211 | public static function define($name, $definition) |
||
| 212 | { |
||
| 213 | static::$defined[$name] = $definition; |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Set grid instance for column. |
||
| 218 | * |
||
| 219 | * @param Grid $grid |
||
| 220 | */ |
||
| 221 | public function setGrid(Grid $grid) |
||
| 222 | { |
||
| 223 | $this->grid = $grid; |
||
| 224 | |||
| 225 | $this->setModel($grid->model()->eloquent()); |
||
|
|
|||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Set model for column. |
||
| 230 | * |
||
| 231 | * @param $model |
||
| 232 | */ |
||
| 233 | public function setModel($model) |
||
| 234 | { |
||
| 235 | if (is_null(static::$model) && ($model instanceof BaseModel)) { |
||
| 236 | static::$model = $model->newInstance(); |
||
| 237 | } |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Set original data for column. |
||
| 242 | * |
||
| 243 | * @param Collection $collection |
||
| 244 | */ |
||
| 245 | public static function setOriginalGridModels(Collection $collection) |
||
| 246 | { |
||
| 247 | static::$originalGridModels = $collection; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Set column attributes. |
||
| 252 | * |
||
| 253 | * @param array $attributes |
||
| 254 | * |
||
| 255 | * @return $this |
||
| 256 | */ |
||
| 257 | public function setAttributes($attributes = [], $key = null) |
||
| 258 | { |
||
| 259 | if ($key) { |
||
| 260 | static::$rowAttributes[$this->name][$key] = array_merge( |
||
| 261 | Arr::get(static::$rowAttributes, "{$this->name}.{$key}", []), |
||
| 262 | $attributes |
||
| 263 | ); |
||
| 264 | |||
| 265 | return $this; |
||
| 266 | } |
||
| 267 | |||
| 268 | static::$htmlAttributes[$this->name] = array_merge( |
||
| 269 | Arr::get(static::$htmlAttributes, $this->name, []), |
||
| 270 | $attributes |
||
| 271 | ); |
||
| 272 | |||
| 273 | return $this; |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Get column attributes. |
||
| 278 | * |
||
| 279 | * @param string $name |
||
| 280 | * |
||
| 281 | * @return mixed |
||
| 282 | */ |
||
| 283 | public static function getAttributes($name, $key = null) |
||
| 284 | { |
||
| 285 | $rowAttributes = []; |
||
| 286 | |||
| 287 | if ($key && Arr::has(static::$rowAttributes, "{$name}.{$key}")) { |
||
| 288 | $rowAttributes = Arr::get(static::$rowAttributes, "{$name}.{$key}", []); |
||
| 289 | } |
||
| 290 | |||
| 291 | $columnAttributes = Arr::get(static::$htmlAttributes, $name, []); |
||
| 292 | |||
| 293 | return array_merge($rowAttributes, $columnAttributes); |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Format attributes to html. |
||
| 298 | * |
||
| 299 | * @return string |
||
| 300 | */ |
||
| 301 | public function formatHtmlAttributes() |
||
| 302 | { |
||
| 303 | $attrArr = []; |
||
| 304 | foreach (static::getAttributes($this->name) as $name => $val) { |
||
| 305 | $attrArr[] = "$name=\"$val\""; |
||
| 306 | } |
||
| 307 | |||
| 308 | return implode(' ', $attrArr); |
||
| 309 | } |
||
| 310 | |||
| 311 | /** |
||
| 312 | * Set style of this column. |
||
| 313 | * |
||
| 314 | * @param string $style |
||
| 315 | * |
||
| 316 | * @return $this |
||
| 317 | */ |
||
| 318 | public function style($style) |
||
| 319 | { |
||
| 320 | return $this->setAttributes(compact('style')); |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Set the width of column. |
||
| 325 | * |
||
| 326 | * @param int $width |
||
| 327 | * |
||
| 328 | * @return $this |
||
| 329 | */ |
||
| 330 | public function width(int $width) |
||
| 331 | { |
||
| 332 | return $this->style("width: {$width}px;max-width: {$width}px;word-wrap: break-word;word-break: normal;"); |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Set the color of column. |
||
| 337 | * |
||
| 338 | * @param string $color |
||
| 339 | * |
||
| 340 | * @return $this |
||
| 341 | */ |
||
| 342 | public function color($color) |
||
| 343 | { |
||
| 344 | return $this->style("color:$color;"); |
||
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Get original column value. |
||
| 349 | * |
||
| 350 | * @return mixed |
||
| 351 | */ |
||
| 352 | public function getOriginal() |
||
| 353 | { |
||
| 354 | return $this->original; |
||
| 355 | } |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Get name of this column. |
||
| 359 | * |
||
| 360 | * @return mixed |
||
| 361 | */ |
||
| 362 | public function getName() |
||
| 363 | { |
||
| 364 | return $this->name; |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * @return string |
||
| 369 | */ |
||
| 370 | public function getClassName() |
||
| 371 | { |
||
| 372 | $name = str_replace('.', '-', $this->getName()); |
||
| 373 | |||
| 374 | return "column-{$name}"; |
||
| 375 | } |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Format label. |
||
| 379 | * |
||
| 380 | * @param $label |
||
| 381 | * |
||
| 382 | * @return mixed |
||
| 383 | */ |
||
| 384 | protected function formatLabel($label) |
||
| 385 | { |
||
| 386 | if ($label) { |
||
| 387 | return $label; |
||
| 388 | } |
||
| 389 | |||
| 390 | $label = ucfirst($this->name); |
||
| 391 | |||
| 392 | return __(str_replace(['.', '_'], ' ', $label)); |
||
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * Get label of the column. |
||
| 397 | * |
||
| 398 | * @return mixed |
||
| 399 | */ |
||
| 400 | public function getLabel() |
||
| 401 | { |
||
| 402 | return $this->label; |
||
| 403 | } |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Set relation. |
||
| 407 | * |
||
| 408 | * @param string $relation |
||
| 409 | * @param string $relationColumn |
||
| 410 | * |
||
| 411 | * @return $this |
||
| 412 | */ |
||
| 413 | public function setRelation($relation, $relationColumn = null) |
||
| 414 | { |
||
| 415 | $this->relation = $relation; |
||
| 416 | $this->relationColumn = $relationColumn; |
||
| 417 | |||
| 418 | return $this; |
||
| 419 | } |
||
| 420 | |||
| 421 | /** |
||
| 422 | * If this column is relation column. |
||
| 423 | * |
||
| 424 | * @return bool |
||
| 425 | */ |
||
| 426 | protected function isRelation() |
||
| 427 | { |
||
| 428 | return (bool) $this->relation; |
||
| 429 | } |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Mark this column as sortable. |
||
| 433 | * |
||
| 434 | * @param null|string $cast |
||
| 435 | * |
||
| 436 | * @return Column|string |
||
| 437 | */ |
||
| 438 | public function sortable($cast = null) |
||
| 439 | { |
||
| 440 | return $this->addSorter($cast); |
||
| 441 | } |
||
| 442 | |||
| 443 | /** |
||
| 444 | * Set cast name for sortable. |
||
| 445 | * |
||
| 446 | * @return $this |
||
| 447 | * |
||
| 448 | * @deprecated Use `$column->sortable($cast)` instead. |
||
| 449 | */ |
||
| 450 | public function cast($cast) |
||
| 451 | { |
||
| 452 | $this->cast = $cast; |
||
| 453 | |||
| 454 | return $this; |
||
| 455 | } |
||
| 456 | |||
| 457 | /** |
||
| 458 | * Set help message for column. |
||
| 459 | * |
||
| 460 | * @param string $help |
||
| 461 | * |
||
| 462 | * @return $this|string |
||
| 463 | */ |
||
| 464 | public function help($help = '') |
||
| 465 | { |
||
| 466 | return $this->addHelp($help); |
||
| 467 | } |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Set column filter. |
||
| 471 | * |
||
| 472 | * @param mixed|null $builder |
||
| 473 | * |
||
| 474 | * @return $this |
||
| 475 | */ |
||
| 476 | public function filter($builder = null) |
||
| 477 | { |
||
| 478 | return $this->addFilter(...func_get_args()); |
||
| 479 | } |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Set column as searchable. |
||
| 483 | * |
||
| 484 | * @return $this |
||
| 485 | */ |
||
| 486 | public function searchable() |
||
| 487 | { |
||
| 488 | $this->searchable = true; |
||
| 489 | |||
| 490 | $name = $this->getName(); |
||
| 491 | $query = request()->query(); |
||
| 492 | |||
| 493 | $this->prefix(function ($_, $original) use ($name, $query) { |
||
| 494 | Arr::set($query, $name, $original); |
||
| 495 | |||
| 496 | $url = request()->fullUrlWithQuery($query); |
||
| 497 | |||
| 498 | return "<a href=\"{$url}\"><i class=\"fa fa-search\"></i></a>"; |
||
| 499 | }, ' '); |
||
| 500 | |||
| 501 | return $this; |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Bind search query to grid model. |
||
| 506 | * |
||
| 507 | * @param Model $model |
||
| 508 | */ |
||
| 509 | public function bindSearchQuery(Model $model) |
||
| 510 | { |
||
| 511 | if ($this->searchable && ($value = request($this->getName())) != '') { |
||
| 512 | $model->where($this->getName(), $value); |
||
| 513 | } |
||
| 514 | } |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Add a display callback. |
||
| 518 | * |
||
| 519 | * @param Closure $callback |
||
| 520 | * |
||
| 521 | * @return $this |
||
| 522 | */ |
||
| 523 | public function display(Closure $callback) |
||
| 529 | |||
| 530 | /** |
||
| 531 | * Display using display abstract. |
||
| 532 | * |
||
| 533 | * @param string $abstract |
||
| 534 | * @param array $arguments |
||
| 535 | * |
||
| 536 | * @return $this |
||
| 537 | */ |
||
| 538 | public function displayUsing($abstract, $arguments = []) |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Display column using array value map. |
||
| 554 | * |
||
| 555 | * @param array $values |
||
| 556 | * @param null $default |
||
| 557 | * |
||
| 558 | * @return $this |
||
| 559 | */ |
||
| 560 | View Code Duplication | public function using(array $values, $default = null) |
|
| 570 | |||
| 571 | /** |
||
| 572 | * Replace output value with giving map. |
||
| 573 | * |
||
| 574 | * @param array $replacements |
||
| 575 | * |
||
| 576 | * @return $this |
||
| 577 | */ |
||
| 578 | public function replace(array $replacements) |
||
| 588 | |||
| 589 | /** |
||
| 590 | * @param string|Closure $input |
||
| 591 | * @param string $seperator |
||
| 592 | * |
||
| 593 | * @return $this |
||
| 594 | */ |
||
| 595 | public function repeat($input, $seperator = '') |
||
| 596 | { |
||
| 597 | if (is_string($input)) { |
||
| 598 | $input = function () use ($input) { |
||
| 599 | return $input; |
||
| 600 | }; |
||
| 601 | } |
||
| 602 | |||
| 603 | if ($input instanceof Closure) { |
||
| 604 | return $this->display(function ($value) use ($input, $seperator) { |
||
| 605 | return join($seperator, array_fill(0, (int) $value, $input->call($this, [$value]))); |
||
| 606 | }); |
||
| 607 | } |
||
| 608 | |||
| 609 | return $this; |
||
| 610 | } |
||
| 611 | |||
| 612 | /** |
||
| 613 | * Render this column with the given view. |
||
| 614 | * |
||
| 615 | * @param string $view |
||
| 616 | * |
||
| 617 | * @return $this |
||
| 618 | */ |
||
| 619 | public function view($view) |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Hide this column by default. |
||
| 630 | * |
||
| 631 | * @return $this |
||
| 632 | */ |
||
| 633 | public function hide() |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Add column to total-row. |
||
| 642 | * |
||
| 643 | * @param null $display |
||
| 644 | * |
||
| 645 | * @return $this |
||
| 646 | */ |
||
| 647 | public function totalRow($display = null) |
||
| 653 | |||
| 654 | /** |
||
| 655 | * Convert file size to a human readable format like `100mb`. |
||
| 656 | * |
||
| 657 | * @return $this |
||
| 658 | */ |
||
| 659 | public function filesize() |
||
| 665 | |||
| 666 | /** |
||
| 667 | * Display the fields in the email format as gavatar. |
||
| 668 | * |
||
| 669 | * @param int $size |
||
| 670 | * |
||
| 671 | * @return $this |
||
| 672 | */ |
||
| 673 | public function gravatar($size = 30) |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Display field as a loading icon. |
||
| 688 | * |
||
| 689 | * @param array $values |
||
| 690 | * @param array $others |
||
| 691 | * |
||
| 692 | * @return $this |
||
| 693 | */ |
||
| 694 | public function loading($values = [], $others = []) |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Display column as an font-awesome icon based on it's value. |
||
| 709 | * |
||
| 710 | * @param array $setting |
||
| 711 | * @param string $default |
||
| 712 | * |
||
| 713 | * @return $this |
||
| 714 | */ |
||
| 715 | public function icon(array $setting, $default = '') |
||
| 729 | |||
| 730 | /** |
||
| 731 | * Return a human readable format time. |
||
| 732 | * |
||
| 733 | * @param null $locale |
||
| 734 | * |
||
| 735 | * @return $this |
||
| 736 | */ |
||
| 737 | public function diffForHumans($locale = null) |
||
| 747 | |||
| 748 | /** |
||
| 749 | * Returns a string formatted according to the given format string. |
||
| 750 | * |
||
| 751 | * @param string $format |
||
| 752 | * |
||
| 753 | * @return $this |
||
| 754 | */ |
||
| 755 | public function date($format) |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Display column as boolean , `✓` for true, and `✗` for false. |
||
| 764 | * |
||
| 765 | * @param array $map |
||
| 766 | * @param bool $default |
||
| 767 | * |
||
| 768 | * @return $this |
||
| 769 | */ |
||
| 770 | public function bool(array $map = [], $default = false) |
||
| 778 | |||
| 779 | /** |
||
| 780 | * Display column as a default value if empty. |
||
| 781 | * |
||
| 782 | * @param string $default |
||
| 783 | * @return $this |
||
| 784 | */ |
||
| 785 | public function default($default = '-') |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Display column using a grid row action. |
||
| 794 | * |
||
| 795 | * @param string $action |
||
| 796 | * |
||
| 797 | * @return $this |
||
| 798 | */ |
||
| 799 | public function action($action) |
||
| 818 | |||
| 819 | /** |
||
| 820 | * Add a `dot` before column text. |
||
| 821 | * |
||
| 822 | * @param array $options |
||
| 823 | * @param string $default |
||
| 824 | * |
||
| 825 | * @return $this |
||
| 826 | */ |
||
| 827 | public function dot($options = [], $default = '') |
||
| 839 | |||
| 840 | /** |
||
| 841 | * @param string $selectable |
||
| 842 | * |
||
| 843 | * @return $this |
||
| 844 | */ |
||
| 845 | View Code Duplication | public function belongsTo($selectable) |
|
| 853 | |||
| 854 | /** |
||
| 855 | * @param string $selectable |
||
| 856 | * |
||
| 857 | * @return $this |
||
| 858 | */ |
||
| 859 | View Code Duplication | public function belongsToMany($selectable) |
|
| 867 | |||
| 868 | /** |
||
| 869 | * Upload file. |
||
| 870 | * |
||
| 871 | * @return $this |
||
| 872 | */ |
||
| 873 | public function upload() |
||
| 877 | |||
| 878 | /** |
||
| 879 | * Upload many files. |
||
| 880 | * |
||
| 881 | * @return $this |
||
| 882 | */ |
||
| 883 | public function uplaodMany() |
||
| 887 | |||
| 888 | /** |
||
| 889 | * If has display callbacks. |
||
| 890 | * |
||
| 891 | * @return bool |
||
| 892 | */ |
||
| 893 | protected function hasDisplayCallbacks() |
||
| 897 | |||
| 898 | /** |
||
| 899 | * Call all of the "display" callbacks column. |
||
| 900 | * |
||
| 901 | * @param mixed $value |
||
| 902 | * @param int $key |
||
| 903 | * |
||
| 904 | * @return mixed |
||
| 905 | */ |
||
| 906 | protected function callDisplayCallbacks($value, $key) |
||
| 924 | |||
| 925 | /** |
||
| 926 | * Set original grid data to column. |
||
| 927 | * |
||
| 928 | * @param Closure $callback |
||
| 929 | * @param int $key |
||
| 930 | * |
||
| 931 | * @return Closure |
||
| 932 | */ |
||
| 933 | protected function bindOriginalRowModel(Closure $callback, $key) |
||
| 939 | |||
| 940 | /** |
||
| 941 | * Fill all data to every column. |
||
| 942 | * |
||
| 943 | * @param array $data |
||
| 944 | * |
||
| 945 | * @return mixed |
||
| 946 | */ |
||
| 947 | public function fill(array $data) |
||
| 968 | |||
| 969 | /** |
||
| 970 | * If current column is a defined column. |
||
| 971 | * |
||
| 972 | * @return bool |
||
| 973 | */ |
||
| 974 | protected function isDefinedColumn() |
||
| 978 | |||
| 979 | /** |
||
| 980 | * Use a defined column. |
||
| 981 | * |
||
| 982 | * @throws \Exception |
||
| 983 | */ |
||
| 984 | protected function useDefinedColumn() |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * Convert characters to HTML entities recursively. |
||
| 1014 | * |
||
| 1015 | * @param array|string $item |
||
| 1016 | * |
||
| 1017 | * @return mixed |
||
| 1018 | */ |
||
| 1019 | protected function htmlEntityEncode($item) |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Find a displayer to display column. |
||
| 1034 | * |
||
| 1035 | * @param string $abstract |
||
| 1036 | * @param array $arguments |
||
| 1037 | * |
||
| 1038 | * @return $this |
||
| 1039 | */ |
||
| 1040 | protected function resolveDisplayer($abstract, $arguments) |
||
| 1048 | |||
| 1049 | /** |
||
| 1050 | * Call Illuminate/Support displayer. |
||
| 1051 | * |
||
| 1052 | * @param string $abstract |
||
| 1053 | * @param array $arguments |
||
| 1054 | * |
||
| 1055 | * @return $this |
||
| 1056 | */ |
||
| 1057 | protected function callSupportDisplayer($abstract, $arguments) |
||
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Call Builtin displayer. |
||
| 1074 | * |
||
| 1075 | * @param string $abstract |
||
| 1076 | * @param array $arguments |
||
| 1077 | * |
||
| 1078 | * @return $this |
||
| 1079 | */ |
||
| 1080 | protected function callBuiltinDisplayer($abstract, $arguments) |
||
| 1102 | |||
| 1103 | /** |
||
| 1104 | * Passes through all unknown calls to builtin displayer or supported displayer. |
||
| 1105 | * |
||
| 1106 | * Allow fluent calls on the Column object. |
||
| 1107 | * |
||
| 1108 | * @param string $method |
||
| 1109 | * @param array $arguments |
||
| 1110 | * |
||
| 1111 | * @return $this |
||
| 1112 | */ |
||
| 1113 | public function __call($method, $arguments) |
||
| 1126 | } |
||
| 1127 |
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: