Bonjour,
Voila je rencontre un petit problème avec mon code.
Voici mon code source
manageCourse.blade.php
@extends('layouts.master')
@section('content')
@include('courses.popup.academic')
@include('courses.popup.program')
@include('courses.popup.level')
@include('courses.popup.shift')
@include('courses.popup.time')
@include('courses.popup.batch')
@include('courses.popup.group')
<div class="row">
<div class="col-lg-12">
<h3 class="page-header"><i class="fa fa-file-text-o"></i>Cours</h3>
<ol class="breadcrumb">
<li><i class="fa fa-home"></i><a href="#">Accueil</a></li>
<li><i class="icon_document_alt"></i>Cours</li>
<li><i class="fa fa-file-text-o"></i>Gérer les cours</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<section class="panel panel-default">
<header class="panel-heading">Gérer les cours</header>
<form class="form-horizontal" action="{{ route('createClass') }}" id="frm-create-class" method="POST">
{{ csrf_field() }}
<input type="hidden" name="active" id="active" value="1">
<div class="panel panel-body" style="border-bottom: 1px solid #ccc">
<div class="form-group">
<div class="col-sm-4">
<label for="academic-year">Année académique</label>
<div class="input-group">
<select class="form-control" name="academic_id" id="academic_id">
<option value="">--------------Choisir-------------</option>
@foreach($academics as $key =>$y)
<option value="{{ $y->academic_id }}">{{ $y->academic }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-academic"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="program">Cours</label>
<div class="input-group">
<select class="form-control" name="program_id" id="program_id">
<option value=""> ------------------------- Choisir -------------------</option>
@foreach($programs as $key =>$p)
<option value="{{ $p->program_id }}">{{ $p->program }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-program"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="level">Niveau</label>
<div class="input-group">
<select class="form-control" name="level_id" id="level_id">
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-level"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="shift">Shift</label>
<div class="input-group">
<select class="form-control" name="shift_id" id="shift_id">
@foreach($shift as $shf)
<option value="{{ $shf->shift_id }}">{{ $shf->shift }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-shift"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="time">Période</label>
<div class="input-group">
<select class="form-control" name="time_id" id="time_id">
@foreach($time as $t)
<option value="{{ $t->time_id }}">{{ $t->time }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-time"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="batch">Batch</label>
<div class="input-group">
<select class="form-control" name="batch_id" id="batch_id">
@foreach($batch as $b)
<option value="{{ $b->batch_id }}">{{ $b->batch }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-batch"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="group">Groupe</label>
<div class="input-group">
<select class="form-control" name="group_id" id="group_id">
@foreach($group as $gr)
<option value="{{ $gr->group_id }}">{{ $gr->groups }}</option>
@endforeach
</select>
<div class="input-group-addon"><span class="fa fa-plus" id="add-more-group"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="startDate">Date de debut</label>
<div class="input-group">
<input type="text" name="start_date" id="start_date" class="form-control">
<div class="input-group-addon"><span class="fa fa-calendar"></span></div>
</div>
</div>
{{------------------------------}}
<div class="col-sm-4">
<label for="endDate">Date de fin</label>
<div class="input-group">
<input type="text" name="end_date" id="end_date" class="form-control">
<div class="input-group-addon"><span class="fa fa-calendar"></span></div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
<button type="submit" class="btn btn-primary">Créer cours </button>
</div>
</form>
<div class="panel panel-default">
</div>
</section>
</div>
</div>
@endsection
@section('script')
<script type="text/javascript">
$('#start_date').datepicker({
changeMonth:true,
changeYear:true,
dateFormat:'dd-mm-yy'
});
$('#end_date').datepicker({
changeMonth:true,
changeYear:true,
dateFormat:'dd-mm-yy'
});
//===============class==============
$('#frm-create-class').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
var url= $(this).attr('action');
$.post(url,data,function(data){
console.log(data);
})
$(this).trigger('reset');
})
//===============group==============
$('#frm-group-create').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
$.post("{{ route('createGroup') }}",data,function(data){
$('#group_id').append($("<option/>",{
value : data.group_id,
text : data.groups
}))
})
$(this).trigger('reset');
})
//===============group==============
$('#add-more-group').on('click',function(e){
$('#group-show').modal('show');
})
//==============batch=================
$('#frm-batch-create').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
$.post("{{ route('createBatch') }}",data,function(data){
$('#batch_id').append($("<option/>",{
value : data.batch_id,
text : data.batch
}))
})
$(this).trigger('reset');
})
//==============batch==================
$('#add-more-batch').on('click',function(e){
$('#batch-show').modal('show');
})
//==============time====================
$('#frm-time-create').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
$.post("{{ route('createTime') }}",data,function(data){
$('#time_id').append($("<option/>",{
value : data.time_id,
text : data.time
}))
})
$(this).trigger('reset');
})
//==============time====================
$('#add-more-time').on('click',function(e){
$('#time-show').modal('show');
})
//=============shift====================
$('#frm-shift-create').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
var shift=$('#shift_id');
$.post("{{ route('createShift') }}",data,function(data){
$(shift).append($("<option/>",{
value : data.shift_id,
text : data.shift,
}));
})
$(this).trigger('reset');
})
//=============shift====================
$('#add-more-shift').on('click',function(){
$('#shift-show').modal('show');
})
//===========level==========
$("#frm-create-class #program_id").on('change',function(e){
var program_id = $(this).val();
var level = $('#level_id');
$(level).empty();
$.get("{{ route('showLevel') }}",{program_id:program_id},function(data){
$.each(data,function(i,l){
$(level).append($('<option/>',{
value : l.level_id,
text : l.level,
}));
})
})
$(this).trigger('reset');
})
//===========level==========
$('#add-more-level').on('click',function(){
var programs = $('#program_id option');
var program = $('#frm-level-create').find('#program_id');
$(program).empty();
$.each(programs,function(i,pro){
$(program).append($("<option/>",{
value : $(pro).val(),
text : $(pro).text(),
}));
});
$('#level-show').modal('show');
});
//===========level==========
$('#frm-level-create').on('submit',function(e){
e.preventDefault();
var data = $(this).serialize();
var url = $(this).attr('action');
$.post(url,data,function(data){
$('#level_id').append($("<option/>",{
value : data.level_id,
text : data.level,
}))
});
$(this).trigger('reset');
});
//==========================academic===========
$('#add-more-academic').on('click',function(){
$('#academic-year-show').modal();
});
//==========academic===========
$('.btn-save-academic').on('click',function(){
var academic = $('#new-academic').val();
$.post("{{ route('postInsertAcademic') }}",{ academic:academic }, function(data){
$('#academic_id').append($("<option/>",{
value : data.academic_id,
text : data.academic
}))
$('#new-academic').val("");
})
});
//=====================program========================
$('#add-more-program').on('click',function(e){
$('#program-show').modal();
});
$('.btn-save-program').on('click', function(){
var program = $('#program').val();
var description = $('#description').val();
$.post("{{ route('postInsertProgram') }}",{ program:program, description:description }, function(data){
$('#program_id').append($("<option/>",{
value : data.program_id,
text : data.program
}))
$('#program').val("");
$('#description').val("");
})
})
</script>
@endsection
CourseController.php
public function createClass(Request $request)
{
if ($request->ajax())
{
return response(MyClass::create($request->all()));
}
}
```
web.php
Route::post('/manage/course/class',['as'=>'createClass','uses'=>'CourseController@createClass']);
```
```
Myclass.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MyClass extends Model
{
protected $table ='classes';
protected $fillable = ['academic_id','level_id','shift_id','time_id','group_id','batch_id','start_date','end_date','active'];
protected $primaryKey = 'class_id';
public $timestamps = false;
}
```
je veux inserer des données dans la table classe
Lorque je valide le formulaire, les données ne sont pas enregistrées dans la base de données.
Aucune erreur php ou laravel ne s'affiche.