我在Laravel 4.1建立模塊化系統。但是我有一個模塊模型的問題。這是我的系統方案。Laravel無法看到模塊的型號在同級車
app/modules
app/modules/product/
app/modules/controllers/ProductController.php
app/modules/controllers/CatalogController.php
app/modules/models/CatalogProductImage.php
app/modules/models/ProductCatalog.php
app/modules/models/CatalogProductImage.php
的問題是,我ProductCatalog模型不能看到我的CatalogProductImage模型,因此它給了我下面的錯誤:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'CatalogProductImage' not found
我不知道原因。這裏談到的代碼:
ProductCatalog.php
<?php namespace App\Modules\Product\Models;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Eloquent;
use App\Modules\Product\Models\CatalogProductImage as CatalogProductImage;
class ProductCatalog extends Eloquent {
protected $table = 'catalog';
protected $primaryKey = 'catalogId';
protected $connection = 'mysql2';
public $timestamps = FALSE; //update time stamp varsa true yap, updated_at ve created_at alanlarını otomatik gunceller
public function category() {
return $this->hasOne('CatalogCategory', 'catalogCategoryId', 'catalogCategoryId');
}
public function images() {
return $this->hasMany('CatalogProductImage', 'catalogId');
}
}
CatalogProductImage.php
<?php namespace App\Modules\Product\Models;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Eloquent;
class CatalogProductImage extends Eloquent {
protected $table = 'catalog_image';
protected $primaryKey = 'catalogImageId';
protected $connection = 'mysql2';
public $timestamps = FALSE; //update time stamp varsa true yap, updated_at ve created_at alanlarını otomatik gunceller
public function catalog() {
return $this->hasMany('ProductCatalog', 'catalogId');
}
}
編輯:我改變了CatalogProductImage從模塊...到App \模塊...但仍沒有按沒有工作。
試舉全路徑應用程序\模塊\產品\型號\ CatalogProductImage – umefarooq
我嘗試了兩種,但它沒有工作:( –
你有沒有問題一個'composer dump-autoload'' –