You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add a new column filter. To achieve this, I need to place a new method similar to "filter" that exists in "Encore\Admin\Grid\Column". Since this is part of a vendor package, I cannot edit it directly. Therefore, my plan is to rewrite this vendor class. I tried using the following code in "AdminServiceProvider". This is a new ServiceProvider I added under config/app.php to make this change.
public function boot() { Admin::booting(function () { $this->app->singleton(\Encore\Admin\Grid\Column::class, \App\Admin\Extensions\Override\Grid\Column::class); }); }
Here my try is to rewrite vendor class method "filter"
`<?php
namespace App\Admin\Extensions\Override\Grid;
use Encore\Admin\Grid\Column as OriginalColumn;
class Column extends OriginalColumn
{
/**
* Set column filter.
*
* @param mixed|null $builder
*
* @return $this
*/
public function filter($builder = null)
{
dd('sss');
return $this->addFilter(...func_get_args());
}
}`
I do not see this change reflected. Could someone help me with rewriting this vendor class?
The text was updated successfully, but these errors were encountered:
Edited "Encore\Admin\Grid\Column" class by adding new method called "open_filter"
/** * Set column open filter. * * @param mixed|null $builder * * @return $this */ public function open_filter($builder = null) { return $this->addOpenFilter(...func_get_args()); }
2. Inside the trait "HasHeader", added "addOpenFilter" method
`protected function addOpenFilter($type = null, $formal = null)
{
if (is_array($type)) {
return $this->addHeader(new CheckOpenFilter($type));
}
if (is_null($type)) {
$type = 'equal';
}
if (in_array($type, ['equal', 'like', 'date', 'time', 'datetime'])) {
return $this->addHeader(new InputOpenFilter($type));
}
if ($type === 'range') {
if (is_null($formal)) {
$formal = 'equal';
}
return $this->addHeader(new RangeOpenFilter($formal));
}
return $this;
}`
3. included CheckOpenFilter, InputOpenFilter and RangeOpenFilter classes to the folder. those actually a copy of InputFilter, CheckFilter and RangeFilter. The only change is below
Updated the inline styling of ul dropdown-menu class element with below
`style="padding: 10px;box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);left: -5px;border-radius: 0; display: block; position: relative;"` display and position updated.
Now, I achieved this by editing vendor files. However, this approach is not allowed and is generally considered a bad practice to meet this requirement. As I mentioned in my question, I was unable to achieve the same result using the rewrite method.
If anyone knows of a better approach to accomplish this without editing the vendor files, please advise.
Description:
I am trying to add a new column filter. To achieve this, I need to place a new method similar to "filter" that exists in "Encore\Admin\Grid\Column". Since this is part of a vendor package, I cannot edit it directly. Therefore, my plan is to rewrite this vendor class. I tried using the following code in "AdminServiceProvider". This is a new ServiceProvider I added under config/app.php to make this change.
public function boot() { Admin::booting(function () { $this->app->singleton(\Encore\Admin\Grid\Column::class, \App\Admin\Extensions\Override\Grid\Column::class); }); }
Here my try is to rewrite vendor class method "filter"
`<?php
namespace App\Admin\Extensions\Override\Grid;
use Encore\Admin\Grid\Column as OriginalColumn;
class Column extends OriginalColumn
{
/**
* Set column filter.
*
* @param mixed|null $builder
*
* @return $this
*/
public function filter($builder = null)
{
dd('sss');
return $this->addFilter(...func_get_args());
}
}`
I do not see this change reflected. Could someone help me with rewriting this vendor class?
The text was updated successfully, but these errors were encountered: