Привет им новые в Laravel 4.2 и им сделать заявление в контроллерах, я сделал мою собственную функцию под названием c_updateSystemUser ($ ID) и вот кодобновление записей в Laravel 4,2
public function c_updateSystemUser($id)
{
//
session_start();
$getsCapt = $_SESSION["captcha"];
$rules = array(
'username' => 'required|min:2|max:50|regex:/^[a-zA-Z0-9\-\s]+$/|exists:dbo_systemusers,SystemUserName,$id',
'description' => 'required|min:1|max:100|regex:/^[a-zA-Z0-9\-\s]+$/',
'usertype' => 'required|numeric',
'capt' => 'required|numeric'
);
$validator = Validator::make(Input::all(), $rules);
// process the inputs given by the user
if ($validator->fails())
{
return Redirect::to('viewsu/' . $id)
->withErrors($validator)
->withInput(Input::except('password'));
}
else
{
// store the values into the database
$su = SystUser::find($id);
$su->SystemUserTypeID = Input::get('usertype');
$su->SystemUserName = Input::get('username');
$su->SystemUserDescription = Input::get('description');
$su->timestamps = false;
$su->save();
Session::flash('message', 'Successfully created system user!');
return Redirect::to('viewsu');
}
}
}
я этого хотел функция, вызываемая при нажатии пользователем кнопки обновления в моем файле просмотра, но при нажатии кнопки она перенаправляется на другую страницу (моя страница создания пользователя). Я не знаю, почему вот код моей формы в мое лезвие
{{ Form::model($su, array('route' =>array('csu.update',$su->SystemUserID),'method'=>'PUT'))}}
<div class="form-group">
{{ Form::label('usertype', 'User Type') }}
{{ Form::select('usertype', [null=>'Please Select user type'] + $sTyp , array('class'=>'form-control'))}}
{{ Form::label('current' , 'Current Type: (unedited) '.$su->SystemType , array('class' => 'label label-primary')) }}
</div>
<div class="form-group">
{{ Form::label('username', 'Username') }}
{{ Form::text('username', $su->SystemUserName, array('class' => 'form-control')) }}
</div>
<div class="form-group">
{{ Form::label('description', 'Description') }}
{{ Form::textarea('description', $su->SystemUserDescription, array('class' => 'form-control','rows' => '3')) }}
</div>
<div class="form-group">
{{ Form::label('captcha', 'CAPTCHA image: ') }}
</br>
{{ HTML::image('http://localhost:8080/laravel3/app/captcha.php', 'alt' , array('width' => 200, 'height' => 35)) }} </br></br>
{{ Form::text('capt', Input::old('capt'), array('class' => 'form-control','placeholder' => 'enter generated captcha')) }}
</div>
{{ Form::submit('Edit System User', array('class' => 'btn btn-primary')) }}
{{ Form::close()}}
Я не знаю, как сделать f ОРМ вызвать функцию public function c_updateSystemUser($id)
в мой контроллер
мой файл контроллер называется systemUsers.php
какие-либо идеи? любая помощь будет оценен
Вы не могли бы оставлять свои сообщения? – ajameswolf
'Route :: resource ('csu', 'systemUsers @ c_storeSU'); Маршрут :: get ('creationu', 'systemUsers @ c_createSystemUser'); Маршрут :: get ('viewsu', 'systemUsers @ c_viewSystemUser'); Route :: get ('viewsu/{id}', array ('as' => 'findSU', 'uses' => 'systemUsers @ c_editSystemUser')); 'здесь маршрут im, используя – BourneShady
Вы не есть маршрут для обработки запроса на размещение? – ajameswolf