配置后,Laravel类未定义:清除

问题描述 投票:0回答:1

应用程序\常数\ ProductConstant.php

<?php

namespace App\Constant;

use App\Constant\BaseConstant;

class ProductConstant extends BaseConstant {

    const TITLE = "title";
}

Product.php

<?php

namespace App\Models;

use App\Constant\ProductConstant;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $table = 'products';

    protected $fillable = [ProductConstant::TITLE, ProductConstant::IMAGE, ProductConstant::EXPIRY_DATE, ProductConstant::MAX_PARTICIPANTS, ProductConstant::TOTAL_PARTICIPANTS];

错误

未定义的类常量'App \ Constant \ ProductConstant :: TITLE'

在我执行了php artisan config:clear之后。我可以知道是什么原因吗?

laravel laravel-5 composer-php
1个回答
0
投票

不要在本地系统中运行php artisan config:clear,它可能会破坏你的项目

删除此文件bootstrap/cache/config.php

并再次运行项目

运行php artisan cache:clear清除.env文件的缓存

© www.soinside.com 2019 - 2024. All rights reserved.