问题描述
我正在尝试使用nova资源中的implode函数将数组转换为字符串,并且工作正常,但是当我尝试下载同一文件时,却显示错误消息“ implode():传递了无效参数.. >
这是我的Nova资源文件..
SubscriptionPlanReport.php:
<?php
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Number;
use NovaItemsField\Items;
use Laravel\Nova\Http\Requests\NovaRequest;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
class SubscriptionPlanReport extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = \App\SubscriptionPlanMgmt::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'id';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id',];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),Text::make('Name','name')->sortable(),Text::make('Plan Type','type'),Number::make('Price','price')->sortable(),Text::make('Validity','validity')->sortable(),Text::make('Features','feature',function(){
return implode(",",$this->feature); //converting array to string
}),];
}
/**
* Get the cards available for the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function cards(Request $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function filters(Request $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [
(new DownloadExcel)->askForWriterType([
\Maatwebsite\Excel\Excel::CSV => __('CSV document'),\Maatwebsite\Excel\Excel::DOMPDF => __('PDF document'),])->withHeadings(),];
}
//hiding Create organization report option
public static function authorizedToCreate(Request $request)
{
return false;
}
//hiding Update option
public function authorizedToUpdate(Request $request)
{
return false;
}
public static $group = 'Reports';
}
提前谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)