2017-04-17 9 views
1

コントローラファイルコード:EmergencyContactsController.phpLaravel 5で[送信]をクリックするとエラーになりますか?

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 
use App\EmergencyContacts; 

class EmergencyContactsController extends Controller 
    { 
    public function __construct() 
    { 
    $this->middleware('auth'); 
} 

public function create(){ 
    return view('patient/emergencycontacts');  
} 
public function store(array $data){ 

    echo '<pre>'; print_r($data); die(); 
} 
} 

ルート・ファイル・コード:

Route::get('/', function() { 
return view('welcome'); 
}); 

Auth::routes(); 

Route::get('/home', '[email protected]'); 
Route::get('/patient/emergency-contacts' , 'patient/[email protected]') ; 

Route::get('/emergencycontacts_create' , 'patient/[email protected]') ; 

//Route::post('/emergncycontacts_store' , 'patient/[email protected]') ; 


Route::post('/emergencycontacts_store', ['uses' => 'patient/[email protected]', 'as' => 'emergencycontacts_store']); 

Route::resource('/patient/emergency-contacts', 'EmergencyContactsController'); 

ブレードファイルコード:患者/ emergencycontacts.blade.php

{!! Form::open(array('route' => 'emergencycontacts_store', 'class' => 'form')) !!} 
<div class="form-group"> 
    {!! Form::label('Salutation') !!} 
    {{ Form::select('salutation', ['Mr.', 'Mrs.', 'Miss.','Ms.']) }} 
    </div> 
<div class="form-group"> 
{!! Form::label('First Name') !!} 
{!! Form::text('firstname', null, array('required', 'class'=>'form-control', 'placeholder'=>'First Name')) !!} 
</div> 
<div class="form-group"> 
{!! Form::label('Last Name') !!} 
{!! Form::text('lastname', null, array('required', 'class'=>'form-control', 'placeholder'=>'Last Name')) !!} 
</div> 
<div class="form-group"> 
{!! Form::label('Relationship') !!} 
{{ Form::select('relationship', ['Father', 'Mother', 'Husband','Wife','Son','Daughter','Uncle','Aunty','Other']) }} 
</div> 
<div class="form-group"> 
{!! Form::label('Phone') !!} 
{!! Form::text('phone', null, array('required'ReflectionException in Container.php line 719: Class App\Http\Controllers\patient/EmergencyContacts does not exist, 'class'=>'form-control', 'placeholder'=>'Phone')) !!} 
</div> 
<div class="form-group"> 
{!! Form::label('Fax') !!} 
{!! Form::text('fax', null, array('class'=>'form-control', 'placeholder'=>'Fax')) !!} 
</div> 
<div class="form-group"> 
{!! Form::submit('Save',array('class'=>'btn btn-primary')) !!} 
</div> 
{{ Form::close() }} 

私が提出しようそれは私に次のエラーを与える。私はlaravelの新人です。 取得エラー:

ReflectionException in Container.php line 719: Class App\Http\Controllers\patient/EmergencyContacts does not exist 
+0

あなたは、コントローラの代わりに、ルート内の名前空間を渡しています名前は –

+0

これでいいの?ルート:: get( '/ home'、 'HomeController @ index');ルート:: get( '/患者/緊急連絡先'、 'patient/EmergencyContacts @ index');ルート:: get( '/ patient/emergencycontacts_create'、 'patient/EmergencyContacts @ create'); Route :: post( '/ patient/emergencycontacts_store'、['uses' => 'EmergencyContactsController @ store'、 'as' => 'emergencycontacts_store']);ルート::リソース( '/ patient/emergency-contacts'、 'EmergencyContactsController'); –

+0

Route :: get( '/ patient/emergency-contacts'、 'EmergencyContactsController @ index'); –

答えて

1

アップデートルート/ web.phpファイルで指定したコントローラのパス:

'[email protected]' 

ストア機能:

public function store(Request $request) 
{ 
    echo '<pre>'; 
    print_r($request->all()); 
    echo '</pre>'; 

} 
+0

コントローラファイルが患者のフォルダ内にありません。コントローラー・フォルダー内にコントローラー・ファイルがありますが、ブレード・ファイルは患者フォルダーにあります。 –

+0

答えが更新されました。ルートファイルのコントローラに間違ったパスを指定しました – Marcin

+0

このルートはRoute :: post( '/ emergencycontacts_store'、['uses' => 'EmergencyContactsController @ store' 'as' => 'emergencycontacts_store']); "今、私はこのエラー "App \ Http \ Controllers \ EmergencyContactsController :: store()"の引数1がありません。 –