在Laravel 5.0中,我在控制器中使用模型時遇到了麻煩。我在App下的模型中創建了該模型。模型ID的代碼描述爲:在Laravel 5中找不到類'app models
<?php namespace App\models;
use Illuminate\Database\Eloquent\Model;
class Observacion extends Model{
protected $table = 'obs_usuarios';
protected $fillable = ['observaciones', 'usuario_id','autor_id','tipo'];
}
部分,我假裝用它控制的代碼是:
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\models\Contrato;
use app\models\Observacion;
use App\models\Perfil;
use Illuminate\Http\Request;
use App\models\Configuracion;
use App\models\Usuario;
use App\models\Categ_profesores;
use Carbon\Carbon;
use Illuminate\Support\Facades\Input;
use Auth;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class SecretariaController extends Controller {
public function observacion($msg,$user_id,$autor_id,$type){
$observacion = new Observacion();
$observacion->observaciones=$msg;
$observacion->usuario_id=$user_id;
$observacion->autor_id=$autor_id;
$observacion->tipo=$type;
$observacion->save();
}
我還送dump-autoload
但我得到這個錯誤:
FatalErrorException in SecretariaController.php line 155:
Class 'app\models\Observacion' not found
線155就是我做的:$observacion = new Observacion();
所以,我不知道車還有什麼CK。
爲'App'使用大寫'A' – Jerodev
@Jerodev謝謝你!那工作 –