コントローラファイルコード: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
あなたは、コントローラの代わりに、ルート内の名前空間を渡しています名前は –
これでいいの?ルート:: 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'); –
Route :: get( '/ patient/emergency-contacts'、 'EmergencyContactsController @ index'); –