2015-03-02 57 views
3

我是laravel的初學者。我嘗試的是作曲家dump-auto,但沒有奏效。UserController.php中的FatalErrorException第39行:未找到'App Http Controllers User'類

此代碼是在Laravel 5.0每個答案將不勝感激。

<?php namespace App\Http\Controllers; 

use App\Http\Requests; 
use App\Http\Controllers\Controller; 

use Illuminate\Http\Request; 

use View, 
    Response, 
    Validator, 
    Input, 
    Mail, 
    Session; 



class UserController extends Controller { 

    /** 
    * Display a listing of the resource. 
    * 
    * @return Response 
    */ 
    public function index() 
    { 
     return view('pages.default'); 
    } 

    /** 
    * Show the form for creating a new resource. 
    * 
    * @return Response 
    */ 
    public function insert() 
    { 

     $ 

     $user = User::create(['u_name' => 'inputName', 'u_eml' => 'inputMail', 'u_contact' => 'inputContact']); 

    } 

    /** 
    * Store a newly created resource in storage. 
    * 
    * @return Response 
    */ 
    public function store() 
    { 
     // 
    } 

    /** 
    * Display the specified resource. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function show($id) 
    { 
     // 
    } 

    /** 
    * Show the form for editing the specified resource. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function edit($id) 
    { 
     // 
    } 

    /** 
    * Update the specified resource in storage. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function update($id) 
    { 
     // 
    } 

    /** 
    * Remove the specified resource from storage. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function destroy($id) 
    { 
     // 
    } 

} 

這是我的模型:user.php的

<?php namespace App; 

use Illuminate\Auth\Authenticatable; 
use Illuminate\Database\Eloquent\Model; 
use Illuminate\Auth\Passwords\CanResetPassword; 
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; 
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; 

class User extends Model implements AuthenticatableContract, CanResetPasswordContract { 

    use Authenticatable, CanResetPassword; 

    protected $table = 'user'; 
    public $timestamps = false;  
} 

回答

7

就在你的上面列表中添加use App\User - 這樣的:

use App\User; 

或者你可以改變你的控制器代碼是\App\User::create(...(注意\開頭)

+1

其實這是'使用App \ User'和'\軟件\用戶::創建(...' – lukasgeiter 2015-03-02 12:14:08

+2

唉...有一天我會實際上得到一個答案:) – Laurence 2015-03-02 12:14:53

+0

非常感謝:)我得到了@TheShiftExchange – Siddharth 2015-03-03 13:21:43

0

在類聲明之前只需添加

use App\user; 

相關問題