mardi 29 mai 2018

Laravel Not Delete record

I working on laravel to build my php project . I can retrieve data from database successfully but I can not delete records when press delete button , I trying to delete record using ajax so this my ajax code

 $('.userdelete').on('click', function() {
   alert('dfsfs');var id=$(this).data('id');
        $.ajax({
            type: 'DELETE',
            url: '/users/' + id,
            data: {
                '_token': $('input[name=_token]').val(),
            },
            success: function(data) {alert(data);
                toastr.success('Successfully deleted Post!', 'Success Alert', {timeOut: 5000});
                $('.item' + data['id']).remove();
            },
              error: function(data) {console.log(data);;

            }

        });
    });

this is the route

  Route::resource('users','radcheckController');

Users Model

  namespace App;

   use Illuminate\Database\Eloquent\Model;

  class Users extends Model
  {
    protected $table="radcheck";

      }

this is the controller's destroy function

public function destroy($id)
{

  $res=Users::where('username',$id)->delete();

}



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

Aucun commentaire:

Enregistrer un commentaire