我知道有关的帖子,我已经尝试了多次尝试达到我的目标,我将在下面详细说明:
我有一个.zip
/ .rar
,包含多个xls
&xlsx
文件.
每个excel文件包含多达数千行的数据,大约90列提供或获取(每个excel文件可以包含更多或更少的列).
我已经创建了一个java windowbuilder应用程序,我在其中选择.zip
/ .rar
文件并选择将这些文件解压缩到哪里并使用它们创建它们FileOutputStream
.保存每个文件后,我正在读取文件的内容.
到现在为止还挺好.在多次尝试避免OOM(OutOfMemory)并加快速度之后,我已经达到了"最终版本"(这非常糟糕,但直到我弄清楚如何正确阅读)我将解释:
File file = new File('certainFile.xlsx'); //or xls, For example purposes
Workbook wb;
Sheet sheet;
/*
There is a ton of other things up to this point that I don't consider relevant, as it's related to unzipping and renaming, etc.
This is within a cycle
/
In every zip file, there is at least 1 or 2 files that somehow, when …
Run Code Online (Sandbox Code Playgroud) 我一直在使用 laravel scout 进行一些测试,并根据文档(https://laravel.com/docs/8.x/scout#configuring-searchable-data),我已将我的用户模型映射为这样:
/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
$data = $this->toArray();
return array_merge($data, [
'entity' => 'An entity'
]);
}
Run Code Online (Sandbox Code Playgroud)
只是为了测试,这就是我在调试时得出的结论。
使用此映射导入用户模型后,我可以在 meilisearch 仪表板上看到它确实显示了用户数据 + 实体 = '一个实体'。
但是,应用此方法时:
User::search('something')->where('entity', 'An entity')->get()
它会产生以下错误:
"message": " --> 1:1\n |\n1 | entity=\"An entity\"\n | ^----^\n |\n = attribute `entity` is not filterable, available filterable attributes are: ",
"exception": "MeiliSearch\\Exceptions\\ApiException",
"file": "/var/www/api/vendor/meilisearch/meilisearch-php/src/Http/Client.php",
Run Code Online (Sandbox Code Playgroud)
回溯查看“可过滤属性”,我得出的结论是:
$client = app(\MeiliSearch\Client::class); …
Run Code Online (Sandbox Code Playgroud) 耐心等待,刚开始测试。
所以,我有这个当前的中间件结构:
class IsActive
{
public function handle($request, Closure $next)
{
if (self::active()) {
return $next($request);
}
Auth::guard('web')->logout();
return redirect('/');
}
protected function active()
{
if (Auth::guard('web')->check()) {
$state = Auth::guard('web')->user()->state;
if ($state == 'enabled') {
return true;
}
}
return false;
}
}
class IsAdmin extends IsActive
{
public function handle($request, Closure $next)
{
if (parent::active()) {
if (Auth::guard('web')->check()) {
$role = Auth::guard('web')->user()->role->name;
if ($role == 'admin' || $role == 'superAdmin') {
return $next($request);
}
}
return redirect('/');
} …
Run Code Online (Sandbox Code Playgroud) 我无法绕过这个,因为我在另一个项目上有这个并且工作得很好.它目前给我这个错误
Symfony\Component\Debug\Exception\FatalErrorException(E_UNKNOWN)Trait'App\Traits\ResponseTrait'未找到
UserRepository工作正常,特性没有.我已经尝试重命名特征,将其移动到存储库文件夹,chmod到777,我不知道什么是错的.
认识我的HomeController,laravel的默认设置:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Repositories\UserRepository as User;
use App\Traits\ResponseTrait;
class HomeController extends Controller
{
use ResponseTrait;
private $user;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//dd($this->user->all()->toArray());
//You can ignore the self:: part, as it doesn't reach this far.
self::setData($this->user->all()->toArray());
return "test";
return view('home');
} …
Run Code Online (Sandbox Code Playgroud) 我有这个包含规则和 withValidator 作为第二层验证的表单请求。
注意:我知道在规则上具有唯一性会抑制此示例的需要,但我需要在这里进行进一步的验证。
public function rules(Request $request) {
return [
"name" => "required|max:191",
"begin_date" => "required|after_or_equal:today|date_format:d-m-Y",
"end_date" => "required|after:begin_date|date_format:d-m-Y",
];
}
public function withValidator($factory) {
$result = User::where('name', $this->name)->get();
if (!$result->isEmpty()) {
$factory->errors()->add('User', 'Something wrong with this guy');
}
return $factory;
}
Run Code Online (Sandbox Code Playgroud)
我确信它会进入,if
因为我之前已经放置了一个 dd 来检查它是否进入内部。但是,它在控制器上继续执行此方法,但我不希望它这样做。
public function justATest(UserRequest $request) {
dd("HI");
}
Run Code Online (Sandbox Code Playgroud) laravel ×3
php ×3
apache-poi ×1
excel ×1
java ×1
laravel-5.6 ×1
laravel-8 ×1
phpunit ×1
testing ×1
traits ×1