lundi 29 août 2016

Date Not Inserted In Database Using Angular js And Laravel

Here i am using angular js iand trying to insert attendence from form attendance-form.blade.php in table attendance on button click. Now the problem is that as i click on button create there is no insertion of data in table attendance.Below is the code i done

In attendance-form.blade.php

<div ui-view="attendanceForm">
<div class="mdl-grid demo-content" ng-controller="AttendanceFormController">
    <div class="demo-charts mdl-color--white mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-grid">
        <form>
            <div class="form-group label-static is-empty">
                <h3>Create Attendance</h3>
                <div class="form-group label-static is-empty">
                    <input type="text" name="user_id" class="attendance-form form-control"
                           id="i2" placeholder="user_id" ng-model="attendance.user_id">
                </div>
                <div class="form-group label-static is-empty">
                    <input type="text" name="in_or_out" class="attendance-form form-control"
                           id="i2" placeholder="in_or_out" ng-model="attendance.in_or_out">
                </div>
                <div class="form-group label-static is-empty">
                    <input type="text" name="comment" class="attendance-form form-control"
                           id="i2" placeholder="comment" ng-model="attendance.comment">
                </div>
                <div class="attendance-form form-group label-static is-empty ripple-container">
                    <input type="button" value="Create" class="btn btn-raised btn-primary" ng-click="abc()">
                </div>

            </div>
        </form>
    </div>
</div>

In AttendanceController.js

app.controller('AttendanceFormController', function ($scope, AttendanceService) {
$scope.attendance = {};
$scope.attendance.user_id
$scope.attendance.in_or_out;
$scope.attendance.comment;

$scope.loadAttendance = function () {
    $scope.user = AttendanceService.get({id:$scope.params.id});
}

$scope.abc = function () {

                                attendance = {user_id:$scope.attendance.user_id,
                                in_or_out:$scope.attendance.in_or_out,
                                comment:$scope.attendance.comment,

    }

    AttendanceService.post(attendance).then(function(response){
        alert('Attendance successfully added in the system.'+'\n'+'Check console.log for response.');
        console.log(response.data);
    });

}

});

In AttendanceFactory.js

app.factory('AttendanceRESTClient', function ($resource) {
return $resource('api/attendance/:id', {id: '@id'}, {
    'query': {method: "POST", isArray: false }
});

})

In AttendanceService.js

var AttendanceService = app.service('AttendanceService', function (AttendanceRESTClient) {
return {
    get: function(id) {
        return AttendanceRESTClient.get({id:id.id}).$promise;
    },

    getEdit:function(id){
        return AttendanceRESTClient.getEdit({id:id.id})
    },

    post: function(attendance){
        return AttendanceRESTClient.save(attendance).$promise;
    },

    all: function(){
        return AttendanceRESTClient.query().$promise;
    },

    edit: function(attendance){
        return AttendanceRESTClient.edit(attendance)
    }
}

})



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2c2Y2uu
via IFTTT

Aucun commentaire:

Enregistrer un commentaire