jeudi 19 novembre 2020

Why my destroy function are not functioning?

i'm doing the destroy function in the controller. Therefore, once click the destroy icon it supposed to delete the data. But it don't do anything and just go to the blank page only.

Here are my coding:

AcademicQualificationController.

public function destroy($id)
    { dd($id);
        //dd($request->all());
        // $pastedu = $this->acadqualification->delete($id);
        return Redirect::to(URL::previous() . "#step-1");
    }

    // public function delete($id)
    // {
    //     dd($id);
    // }
    //
    /* DataTables*/
    //
    public function getData(Request $request)
    {
        $academic_qualification = AcademicQualification::select('academic_qualifications.*', 'institutions.name as institution', 'education_levels.name as qualification')
            ->join('institutions', 'academic_qualifications.institution_id', '=', 'institutions.id')
            ->join('education_levels', 'academic_qualifications.education_level_id', '=', 'education_levels.id')
            ->whereNull('academic_qualifications.deleted_at')
            ->where('academic_qualifications.staff_id', $request['id']);

        $datatables = DataTables::make($academic_qualification)
            ->addIndexColumn()
            ->addColumn('institute', function ($academic_qualification) {
                return $academic_qualification->institution;
            })
            ->addColumn('qualification', function ($academic_qualification) {
                return $academic_qualification->qualification;
            })
            ->addColumn('action', function ($academic_qualification) {
                $html = Forms::iconUpdate('#', [
                    'data-toggle' => 'modal',
                    'data-title'  => msg('lbl_update_academic_qualification'),
                    'data-target' => '#modal_global_form',
                    'data-url'    => route('academic_qualification.edit', ['staff_id' => $academic_qualification->staff_id, 'acad_id' => $academic_qualification->id]),
                    'data-action' => route('academic_qualification.update', ['staff_id' => $academic_qualification->staff_id, 'acad_id' => $academic_qualification->id]),
                    'data-size'   => 'modal-lg',
                ]) . " ";
                $html .= Forms::iconDelete(route('academic_qualification.destroy', ['acad_id' => $academic_qualification->id]), 'class="sa2_delete"') . " ";
                // $html .= Form::iconDelete(route('area_of_interest_detail.destroy', $id), 'class="sa2_delete"') . " ";
                return $html;
            })
            ->rawColumns(['action'])
            ->toJson();

        return $datatables;

        //
    }

This is my view blade: list.blade.php


<div class="panel panel-default">
    <div class="panel-heading">
        <h4></h4>
    </div>
    <div class="panel-body">
        <div class="form-horizontal">
            <div class="form-group">
                    <label class="col-lg-2 control-label">{!! msg('lbl_education_level') !!}</label>
                <div class="col-lg-4">
                    {!! Form::dropdown('education_level_id', $edulevelselection, '', 'class="select2-form edulevel"') !!}
                </div>
                <span>
                    {!! Form::buttonAdd('','#',[
                    'data-toggle' => 'modal',
                    'id' => 'education',
                    'data-title' => msg('lbl_new_academic_qualification'),
                    'data-target' => '#modal_global_form',
                    'data-url' => route('academic_qualification.create', [ 'id' => $staff_id] ),
                    'data-action' => route('academic_qualification.store'),
                    'data-size' => 'modal-lg',
                    'data-param' => '{ }'
                    ]) !!}
                </span>
            <div>
        </div>
        <div class="table-responsive">
            <table id="academic_qualification-table" class="table table-striped b-t b-b">
            </table>
        </div>
    </div>
    <div class="m-t-xl">
            <input type='button' class='btn btn-default button-previous' name='previous' value='Previous' />
            {!! Form::buttonSave('save & continue','',[
            'id' => 'submit-application',
            'class' => 'button-next pull-right'
            ]) !!}
    </div>
</div>

@push('scripts')

@endpush

<script type="text/javascript">

    $(".select2-form").select2({
    placeholder: "Please Select",
    allowClear: true
    });

    $("select[name=education_level_id]").change(function(e){
    var edulevelid = $('.edulevel').val();
    console.log(edulevelid);
    $('a[data-param]').attr('data-param','{"education_level_id":'+edulevelid+'}');
    });

    var table = $('#academic_qualification-table').DataTable({
    {!! Config::get('datatable.setting') !!}
    ajax: '{!! route('academic_qualification.postData', ['id' => $staff_id]) !!}',
    columns: [
        { sTitle: 'No', mData: 'DT_Row_Index', width:'5%' },
        { sTitle: '', mData: 'institution' },
        { sTitle: '', mData: 'qualification' },
        { sTitle: '', mData: 'grade' },
        { sTitle: '', mData: 'year' },
        { sTitle: '', mData: 'action' },
    ],
    });

    </script>


This is my route:

Route::resource('academic_qualification', 'Setting\General\AcademicQualificationController');

The view of system: before click the delete button enter image description here

after click the delete button enter image description here

The page just blank. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire