laravel unable to save.

Greetings, currently I want to view gantt based on project id. I manage to do it. I have updated latest version of dhtmlxGantt. This is my source code in GanttController.php. By the way, I am using Laravel Connector. But the current problem is I am trying to save new changes made in the gantt html page. It seems not working. I have read Gantt API,but I am so confused right now. Please guide. Which method should i use onAfterTaskUpdate or onBeforeTaskUpdate.? or need to use dataprocessor API? Below is the source code and screenshot of error.




<div id="gantt_here" style='width:100%; height:250px;margin-top:50px;'></div>

<script type="text/javascript">
    //gantt.config.xml_date = "%Y-%m-%d %H:%i:%s";
    gantt.config.xml_date="%Y-%m-%d %H:%i";
    gantt.config.step = 1;
    gantt.config.scale_unit= "day";

    gantt.init("gantt_here", new Date(2010,7,1), new Date(2010,8,1));
    gantt.load("./gantt_data", "xml");

    gantt.attachEvent("onAfterTaskUpdate", function(id,item){

    var dp = new dataProcessor("./gantt_data");

Google Chrome Console

why do you need these lines? gantt.attachEvent("onAfterTaskUpdate", function(id,item){ gantt.updateTask(id); });
gantt.updateTask fires onAfterTaskUpdate event, so you’ve got an infinite loop which result in maximum call stack error that is shown in browser console

Well as I said, I could not save. So, i use onAfterUpdateTask trigger to save the updated task.

onAfterTaskUpdate event fires right after gantt.updateTask was called, which means that if your event handler is called, .updateTask was called already. Calling it again would only cause maximum call stack error which you’ve seen before.

What do you mean by you could not save changes? Was there any client-side or server side errors? Have you tried enabling server logging?

I have enabled error logging. But nothing shows in my log file.



but in laravel.log file,there is an error which is

[2016-02-25 11:17:25] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method stdClass::save()' in C:\xampp\htdocs\sspmt\vendor\dhtmlx\connector-php\codebase\Dhtmlx\Connector\DataStorage\PHPLaravelDBDataWrapper.php:55

I tried paste the “POST” query to find out the error. Looks like id not found. but what id?
Ajax have send task id,project id. in other word,it sends everything already.

var formData = {
  "17_!nativeeditor_status": "updated",
  "17_duration": "2",
  "17_end_date": "2010-08-11 00:00:00",
  "17_id": "17",
  "17_parent": "16",
  "17_progress": "0.8785714285714286",
  "17_project_id": "2",
  "17_start_date": "2010-08-09 00:00:00",
  "17_text": "Task 2.1",
  "ids": "17"
$.post('http://localhost:8000/gantt_data?editing=true&gantt_mode=tasks', formData)
  .done (showResult)
  "frameId": 0,
  "method": "POST",
  "parentFrameId": -1,
  "requestBody": {
    "formData": {
      "17_!nativeeditor_status": [
      "17_duration": [
      "17_end_date": [
        "2010-08-11 00:00:00"
      "17_id": [
      "17_parent": [
      "17_progress": [
      "17_project_id": [
      "17_start_date": [
        "2010-08-09 00:00:00"
      "17_text": [
        "Task 2.1"
      "ids": [
  "requestId": "11565",
  "tabId": 148,
  "timeStamp": 1456374302441.745,
  "type": "xmlhttprequest",
  "url": "http://localhost:8000/gantt_data?editing=true&gantt_mode=tasks"

PS:// I use chrome extension JQuery AJAX Capture and laravel-debugbar

This is screenshot laravel error

The related code is quite simple

if (!isset($_POST["ids"])) throw new Exception("Incorrect incoming data,

So, the only case when error can occur, is the case when $_POST[“ids”] is not available.

sorry mate, i am still newbie php oop practise.I still dont understand your comment.
Just an update, somehow i manage to find the error log that generated from this code in my controller.


Below is what i get from the error log

Log started, 25/02/2016 03:07:37

DataProcessor object initialized
16_id => 16
16_start_date => 2010-08-08 00:00:00
16_duration => 2
16_text => Project 2
16_progress => 0.6392857142857142
16_parent => 0
16_project_id => 2
16_end_date => 2010-08-10 00:00:00
16_!nativeeditor_status => updated
17_id => 17
17_start_date => 2010-08-09 00:00:00
17_duration => 2
17_text => Task 2.1
17_progress => 0.30714285714285716
17_parent => 16
17_project_id => 2
17_end_date => 2010-08-11 00:00:00
17_!nativeeditor_status => updated
19_id => 19
19_start_date => 2010-08-10 00:00:00
19_duration => 3
19_text => Task 2.2
19_progress => 0.5333333333333333
19_parent => 16
19_project_id => 2
19_end_date => 2010-08-13 00:00:00
19_!nativeeditor_status => updated
1456383984951_id => 1456383984951
1456383984951_!nativeeditor_status => deleted
ids => 16,17,19,1456383984951

Row data [16]
id => 16
start_date => 2010-08-08 00:00:00
duration => 2
text => Project 2
progress => 0.6392857142857142
parent => 0
project_id => 2
end_date => 2010-08-10 00:00:00
!nativeeditor_status => updated

Non-static method Illuminate\Database\Eloquent\Collection::find() should not be called statically, assuming $this from incompatible context at C:\xampp\htdocs\sspmt\vendor\dhtmlx\connector-php\codebase\Dhtmlx\Connector\DataStorage\PHPLaravelDBDataWrapper.php line 54

Undefined property: Dhtmlx\Connector\DataStorage\PHPLaravelDBDataWrapper::$items at C:\xampp\htdocs\sspmt\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Collection.php line 23

Invalid argument supplied for foreach() at C:\xampp\htdocs\sspmt\vendor\laravel\framework\src\Illuminate\Support\Arr.php line 152

Creating default object from empty value at C:\xampp\htdocs\sspmt\vendor\dhtmlx\connector-php\codebase\Dhtmlx\Connector\DataStorage\PHPLaravelDBDataWrapper.php line 65

Please try to update the component to the latest version ( it will be 3.0.3 ), it can be done through Composer. Or you can download and update files from github. … /tag/3.0.3

Please try to update the component to the following version through downloading and updating files from github.

This version contains some changes for Gantt connector for Laravel framework. And some notes:

  1. If you don’t want to use the filtration feature, then just use the following code inside your controller (just an example):
$connector = new GanttConnector(null, "PHPLaravel");
$connector->render_links(new GanttLink(), "id", "source,target,type");
$connector->render_table(new GanttTask(), "id", "start_date,duration,text,progress,parent");
  1. If you want to use the filtration or other features, then just use one of the following options of the code in your controller (just examples with fake conditions):

a) Through the creation of new model instance:

$connector = new GanttConnector(null, "PHPLaravel");
$link = new GanttLink();
$task = new GanttTask();
$connector->render_links($link->where('id', '>', 0), "id", "source,target,type");
$connector->render_table($task->where('id', '>', 60), "id", "start_date,duration,text,progress,parent");

b) Through the call of any static method without the new model instance creation:

$connector = new GanttConnector(null, "PHPLaravel");
$connector->render_links(GanttLink::where('id', '>', 0), "id", "source,target,type");
$connector->render_table(GanttTask::where('id', '>', 50), "id", "start_date,duration,text,progress,parent");

Note: don’t use the ->get() method after calling ‘where’ and other methods.

$connector = new GanttConnector(null, "PHPLaravel");
        $link = new GanttLink();
        $task = new GanttTask();
        $connector->render_links(new GanttLink(), "id", "source,target,type");
        $connector->render_table($task->where('projectid', '=', 1), "id", "start_date,duration,text,progress,parent,projectid");

Thanks mate. I have update the vendor/dhtmlx/connector-php/codebase/your-codes from githubs

and modify GanntController with your code. It Works like charms. Thanks