我正在尝试将build工具转换为资源工具。我尝试将我的工具更改为扩展ResourceTool而不是Tool,并将资源工具添加到字段中的Resource中,但是它没有出现。我还修改了ToolServiceProvider的代码,使其与ResourceTool的代码相匹配,但不幸的是,它无法工作。
我在网上搜索过,但我似乎是唯一一个有这个问题的人,任何人都经历过这个问题,知道该怎么做吗?我没有收到任何错误信息,只是资源工具没有出现。
这是我的代码,为了可读性和保密性,我删除了其中的一些代码。
产品(资源)
<?php
namespace App\Nova;
use confidentiality\SalesHistory\SalesHistory;
class Product extends Resource
{
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
SalesHistory::make(),
];
}
}SalesHistory (资源工具)
<?php
namespace confidentiality\SalesHistory;
use Laravel\Nova\ResourceTool;
class SalesHistory extends ResourceTool
{
/**
* Get the displayable name of the resource tool.
*
* @return string
*/
public function name()
{
return 'Sales History';
}
/**
* Get the component name for the resource tool.
*
* @return string
*/
public function component()
{
return 'sales-history';
}
}ToolServiceProvider (资源工具)
<?php
namespace confidentiality\SalesHistory;
use Laravel\Nova\Nova;
use Laravel\Nova\Events\ServingNova;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class ToolServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app->booted(function () {
$this->routes();
});
Nova::serving(function (ServingNova $event) {
Nova::script('sales-history', __DIR__.'/../dist/js/tool.js');
Nova::style('sales-history', __DIR__.'/../dist/css/tool.css');
});
}
/**
* Register the tool's routes.
*
* @return void
*/
protected function routes()
{
if ($this->app->routesAreCached()) {
return;
}
Route::middleware(['nova'])
->prefix('nova-vendor/sales-history')
->group(__DIR__.'/../routes/api.php');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}发布于 2019-05-22 10:47:07
我终于修好了。我还必须更改tool.js文件以与资源工具的文件匹配。
Nova.booting((Vue, router, store) => {
Vue.component('sales-history', require('./components/Tool'))
})https://stackoverflow.com/questions/56254914
复制相似问题