Код: Выделить всё
{{ Form::open(array('route' => array('edit_spk', 'id'=> $spk_data->id), 'method' => 'GET', 'style' => 'display:inline')) }}
[i][/i] Edit
{{Form::close()}}
Код: Выделить всё
Route::get('spk/edit/{id}', array('as'=>'edit_spk','uses'=>'SpkController@edit'));
Route::put('spk/update/{id}', array('as'=>'update_spk','uses'=>'SpkController@update'));
Код: Выделить всё
public function edit($id){
$spk = Spk::find($id);
$spk->distribution_code=Input::get('distribution_code');
$spk->destination=Input::get('destination');
$spk->hlr=Input::get('hlr');
$spk->first_iccid=Input::get('first_iccid');
$spk->last_iccid=Input::get('last_iccid');
$spk->quantity=Input::get('quantity');
return View::make('modals.edit-spk', compact('spk'));
}
public function update($id) {
$rules = array(
'distribution_code' => 'required',
'destination' => 'required',
'hlr'=> 'required',
'first_iccid' => 'required',
'last_iccid' => 'required',
'quantity' => 'required'
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('modals.edit-spk')->withErrors($validator);
} else {
// store
$update = Spk::find($id);
$update->distribution_code=Input::get('distribution_code');
$update->destination=Input::get('destination');
$update->hlr=Input::get('hlr');
$update->first_iccid=Input::get('first_iccid');
$update->last_iccid=Input::get('last_iccid');
$update->quantity=Input::get('quantity');
$update->save();
// redirect
Session::flash('message', 'Successfully updated SPK !');
return Redirect::to('spk_view');
}
}
Код: Выделить всё
@extends('dashboard.dashboard')
@section('content')
@if (Session::has('message'))
{{ Session::get('message') }}
@endif
[h4] {{link_to('dashboard','Home');}} > {{link_to('spk_view','SPK');}} > Update SPK[/h4]
Update SPK
{{ Form::model($spk,array('method' => 'PUT', 'class'=>'form-horizontal','route'=>array('update_spk', $spk->id))) }}
Distribution Code
M99/99/99/9999
{{ $errors->first('distribution_code',
'
×
Anda belum mengisi data dengan benar !
') }}
Destination
{{ $errors->first('destination',
'
×
Anda belum mengisi data dengan benar !
') }}
HLR
{{ $errors->first('hlr',
'
×
Anda belum mengisi data dengan benar !
') }}
First ICCID
{{ $errors->first('first_iccid',
'
×
Anda belum mengisi data dengan benar !
') }}
Last ICCID
{{ $errors->first('last_iccid',
'
×
Anda belum mengisi data dengan benar !
') }}
Quantity
{{ $errors->first('quantity',
'
×
Anda belum mengisi data dengan benar !
') }}
{{ Form::submit('Update SPK', array('class' => 'btn btn-primary btn-line btn-rect')) }}
{{Form::close()}}
@stop
"Неопределенное свойство: Illuminate\Database\Eloquent\Collection::$id (View: C:\XAMPP\htdocs\ims2\app\views\modals\edit-spk.blade.php)"
Подробнее здесь: https://stackoverflow.com/questions/300 ... in-laravel
Мобильная версия