2015-05-12 88 views
0

我有一個名爲shop1的數據庫,並且存在表聯繫人當我想使用聯繫人模型查看錶中的行時,我使用聯繫人模型訪問表聯繫人工作正常,但是當我想編輯錯誤拋出到我臉上任何幫助致命錯誤異常類未找到類'聯繫人'laravel 5

這裏是我的聯繫控制器

<?php namespace App\Http\Controllers; 

use App\contact; 
use Illuminate\Http\Request; 
use Illuminate\Database\Eloquent\Model; 

class ContactController extends Controller 
{ 

//use contact; 




    public function index() 
{ 
// Show a listing of books. 
$contacts = contact::all(); 

return View('index', compact('contacts')); 

} 
public function create() 
{ 

return view('contactform'); 
} 





public function handleCreate(Request $request) 
{ 


$contact = contact::create([ 
      'fname' => $request->input('first_name'), 
      'lname' => $request->input('last_name'), 
      'phone' => $request->input('phone_number'), 
      'email' => $request->input('email'), 
      'houseno' => $request->input('house'), 
      'kebele' => $request->input('kebele'), 
      'city' => $request->input('city'), 
      'state' => $request->input('state'), 
      'country' => $request->input('country'), 
     ]); 

} 


public function edit(contact $contact) 
{ 
// Show the edit book form. 

return View('edit', compact('contact')); 
} 

public function handleEdit(Request $request) 
{ 
// Handle edit form submission. 
$contact = contact::findOrFail($request->input('id')); 
$contact = contact::update([ 
      'fname' => $request->input('first_name'), 
      'lname' => $request->input('last_name'), 
      'phone' => $request->input('phone_number'), 
      'email' => $request->input('email'), 
      'houseno' => $request->input('house'), 
      'kebele' => $request->input('kebele'), 
      'city' => $request->input('city'), 
      'state' => $request->input('state'), 
      'country' => $request->input('country'), 
     ]); 


return Redirect::action('[email protected]'); 

} 

} 

她是我的編輯視圖

<!DOCTYPE html> 

     <h1>Create employe <small>go on</small></h1> 



<form action="{{ action('[email protected]') }}" method="post" role="form"> 
    <input type="hidden" name="id" value="{{ $contact->id }}"> 
<input type="hidden" name="_token" value="{{ csrf_token() }}"> 

<label for="first_name" id="first_name" >first_name</label> 
<input name="first_name" type="text" id="first_name" class="form-control" value="{{ $contact->fname }}"></br> 
<label for="last_name" id="last_name">last_name</label> 
<input name="last_name" type="text" id="last_name" class="form-control" value="{{ $contact->lname }}"></br> 
<label for="email" id="email">email</label> 
<input name="email" type="text" id="email" class="form-control" value="{{ $contact->email }}"></br> 
<label for="phone_number" id="phone_number">phone_number</label> 
<input name="phone_number" type="phone_number" id="phone_number" class="form-control" value="{{ $contact->phone }}"></br> 
<label for="house" id="house">house</label> 
<input name="house" type="text" id="house" class="form-control" value="{{ $contact->houseno }}"></br> 
<label for="kebele" id="kebele" >kebele</label> 
<input name="kebele" type="text" id="kebele" class="form-control" value="{{ $contact->kebele }}"></br> 
<label for="city" id="city">city</label> 
<input name="city" type="text" id="city" class="form-control" value="{{ $contact->city }}"></br> 
<label for="state" id="state">state</label> 
<input name="state" type="text" id="state" class="form-control" value="{{ $contact->state }}"></br> 
<label for="country" id="country">country</label> 
<input name="country" type="text" id="country" class="form-control" value="{{ $contact->country }}"></br> 

<input type="submit" value="Save" class="btn btn-primary" /> 
     <a href="{{ action('[email protected]') }}" class="btn btn-link">Cancel</a> 
    </form> 

    </form 

>

她是我的模型

<?php namespace App; 

use Illuminate\Database\Eloquent\Model; 

class contact extends Model { 

    //protected $table = 'contacts'; 
    protected $fillable = array('fname','lname','phone','email','houseno','city','kebele','state','country'); 

} 

,這裏是我的路線

<?php 
use Illuminate\Database\Eloquent\Model; 
use Illuminate\Http\Request; 
use App\contact; 
Route::get('/cre/{contact}', '[email protected]'); 
Route::post('/cre', '[email protected] 

「);

的錯誤是這樣

FatalErrorException in compiled.php line 7038: 
Class 'contact' not found 
+0

是型號名稱contact.php或Contact.php? –

+0

是否在添加新類後運行了「composer dump-autoload」? –

+0

contact.php和是的,我運行作曲家轉儲自動加載 – user3266023

回答

0

嘗試運行php artisan clear-compiled

+0

請嘗試添加更多關於該命令如何提供問題解決方案的詳細信息。這樣,OP(和其他任何人)將能夠更好地理解你的答案。 – dhh

相關問題