Php Laravel 5:无法重新声明应用程序\订阅::$fillable
因此,当我在我的Laravel 5网站上发布请求时,我出现了以下错误:Php Laravel 5:无法重新声明应用程序\订阅::$fillable,php,laravel,laravel-5,error-handling,eloquent,Php,Laravel,Laravel 5,Error Handling,Eloquent,因此,当我在我的Laravel 5网站上发布请求时,我出现了以下错误: Cannot redeclare App\Subscription::$fillable 这是我的SubscriptionController.php文件。该错误是在我尝试发布到localhost/subscription时引起的,它调用了我尝试在其中创建订阅类的store方法,但导致了错误 我已经尝试用另一种方法创建订阅实例,但这会导致相同的问题 <?php namespace App\Http\Controll
Cannot redeclare App\Subscription::$fillable
这是我的SubscriptionController.php文件。该错误是在我尝试发布到localhost/subscription时引起的,它调用了我尝试在其中创建订阅类的store方法,但导致了错误
我已经尝试用另一种方法创建订阅实例,但这会导致相同的问题
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Subscription;
use App\Http\Requests;
use App\Http\Requests\StoreSubscriptionRequest;
use App\Http\Controllers\Controller;
class SubscriptionController extends Controller
{
public function __construct()
{
//$this->middleware('auth');
}
public function index(Request $request)
{
return view('subscriptions.index');
}
public function store(StoreSubscriptionRequest $request)
{
$sub = new Subscription;
}
}
使用以下说明:
protected $fillable = ['name'];
protected $fillable = ['surname'];
多次声明相同的$filleble
字段,每次将其设置为一个元素的数组
相反,您应该将一个字段声明为多个元素的数组:
protected $fillable = ['name', 'surname', 'street', 'city', 'postal', 'participants', 'colors1', 'colors2'];
您正在尝试重新声明相同的变量8次
protected $fillable = ['name', 'surname', 'street', 'city', 'postal', 'participants', 'colors1', 'colors2'];