运行我的Web应用程序时出现以下错误:
[Fri Jan 15 19:25:23 2021] PHP Fatal error: Cannot declare class App\Http\Livewire\Customer because the name is already in use in /home/<username>/Projects/<project_name>/app/Http/Livewire/Customer.php on line 9
声明错误基本上是在抱怨它自己的文件,我不确定为什么。这是Customer.php文件的内容:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Livewire\WithPagination;
use App\Models\Customer;
use Illuminate\Support\Facades\Auth;
class Customer extends Component
{
use WithPagination;
public function render()
{
$customers = Customer::where('user_id', Auth::id())->paginate(9);
return view('livewire.customer')->with(['customers' => $customers]);
}
}
有人可以帮我解决这个问题吗?
要解决冲突,只需使用
use App\Models\Customer as AppCustomer;
然后您的班级可以使用AppCustomer
而不是Customer
。
$customers = AppCustomer::where('user_id', Auth::id())->paginate(9);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句