Laravel 5:无法重新声明App\Subscription :: $ fillable

Jen*_*the 3 php error-handling laravel eloquent laravel-5

所以当我在Laravel 5网站上发布帖子请求时出现此错误:

Cannot redeclare App\Subscription::$fillable
Run Code Online (Sandbox Code Playgroud)

这是我的SubscriptionController.php文件.当我尝试发布到localhost/subscription时会导致错误,localhost/subscription调用我尝试创建Subscription类的store方法,但会导致错误.

我已经尝试在另一个方法中创建一个Subscription实例,但这会导致同样的问题.

<?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;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的Subscription.php文件.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Subscription extends Model
{
     protected $fillable = ['name'];
     protected $fillable = ['surname'];
     protected $fillable = ['street'];
     protected $fillable = ['city'];
     protected $fillable = ['postal'];
     protected $fillable = ['participants'];
     protected $fillable = ['colors1'];
     protected $fillable = ['colors2'];
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Mop*_*ppo 5

有了这些说明:

 protected $fillable = ['name'];
 protected $fillable = ['surname'];
Run Code Online (Sandbox Code Playgroud)

$fillable多次声明相同的字段,并且每次将其设置为一个元素的数组.

相反,您应该将一个字段声明为许多元素的数组:

protected $fillable = ['name', 'surname', 'street', 'city', 'postal', 'participants', 'colors1', 'colors2'];
Run Code Online (Sandbox Code Playgroud)