Laravel Form Ekleme-Güncelleme
1-Önce Modelde tanımlama yapıyoruz.
2- Form elemanlarını tanımlıyoruz
 
protected $table = 'training_unit';
    /**
     * @var array
     */
    protected $fillable = [
        'name', 'etiket','slug', 'type', 'training_type', 'html5_path', 'html5_demo_path', 'html5_time',
        'course_id', 'cdn_path', 'pdf', 'total_question', 'options', 'exam_time'
    ];
2- Form elemanlarını tanımlıyoruz
{{ Form::text('name', Input::old('name', $training->name), ['class' => 'form-control', 'id' => 'name', 'required', 'autocomplete' => 'off']) }}
      
3-Formu kaydediyoruz$data = Input::except('_token');
 Yeni oluşturulacaksa
$model = Training::create($data); 
Güncelleme yapılacaksa$model = Training::find($id);  $model->fill($data);
Comments
Post a Comment