fixed
This commit is contained in:
parent
1822a71840
commit
f5efcc1b8d
|
|
@ -34,7 +34,7 @@ class PluginController extends Controller
|
|||
public function edit(Request $request, $code)
|
||||
{
|
||||
$plugin = (new Manager)->getPlugin($code);
|
||||
dd($plugin);
|
||||
dd($plugin, $plugin->getColumns());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Beike\Plugin;
|
||||
|
||||
use Beike\Models\Setting;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -100,12 +101,37 @@ class Plugin implements Arrayable, \ArrayAccess
|
|||
return admin_route('plugins.edit', ['code' => $this->code]);
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
/**
|
||||
* 获取插件对应的设置字段, 并获取已存储在DB的字段值
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns(): array
|
||||
{
|
||||
if (empty($this->columns)) {
|
||||
return [];
|
||||
}
|
||||
$existValues = $this->getColumnsFromDb();
|
||||
foreach ($this->columns as &$column) {
|
||||
$dbColumn = $existValues[$column['name']] ?? null;
|
||||
if (empty($dbColumn)) {
|
||||
$column['value'] = null;
|
||||
continue;
|
||||
}
|
||||
$column['value'] = $dbColumn->value;
|
||||
}
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
|
||||
private function getColumnsFromDb()
|
||||
{
|
||||
return Setting::query()->where('type', 'plugin')
|
||||
->where('space', $this->code)
|
||||
->get()->keyBy('name');
|
||||
}
|
||||
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return (array)array_merge([
|
||||
|
|
|
|||
Loading…
Reference in New Issue