{"action":"created","issue":{"url":"https://api.github.com/repos/freshbitsweb/laratables/issues/19","repository_url":"https://api.github.com/repos/freshbitsweb/laratables","labels_url":"https://api.github.com/repos/freshbitsweb/laratables/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/freshbitsweb/laratables/issues/19/comments","events_url":"https://api.github.com/repos/freshbitsweb/laratables/issues/19/events","html_url":"https://github.com/freshbitsweb/laratables/issues/19","id":371832725,"node_id":"MDU6SXNzdWUzNzE4MzI3MjU=","number":19,"title":"relation failing","user":{"login":"jim1506","id":123184,"node_id":"MDQ6VXNlcjEyMzE4NA==","avatar_url":"https://avatars1.githubusercontent.com/u/123184?v=4","gravatar_id":"","url":"https://api.github.com/users/jim1506","html_url":"https://github.com/jim1506","followers_url":"https://api.github.com/users/jim1506/followers","following_url":"https://api.github.com/users/jim1506/following{/other_user}","gists_url":"https://api.github.com/users/jim1506/gists{/gist_id}","starred_url":"https://api.github.com/users/jim1506/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jim1506/subscriptions","organizations_url":"https://api.github.com/users/jim1506/orgs","repos_url":"https://api.github.com/users/jim1506/repos","events_url":"https://api.github.com/users/jim1506/events{/privacy}","received_events_url":"https://api.github.com/users/jim1506/received_events","type":"User","site_admin":false},"labels":[{"id":731792386,"node_id":"MDU6TGFiZWw3MzE3OTIzODY=","url":"https://api.github.com/repos/freshbitsweb/laratables/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-19T07:10:11Z","updated_at":"2018-10-21T13:02:29Z","closed_at":null,"author_association":"NONE","body":"I have a table of advertisers and one of regions. The advertiser has a field region_id and is defined as a belongs to relationship. Laratables is not picking up the relationship. The regions table has a field region which is what I wish to show.\r\n\r\nThe relationship is defined as\r\n\r\n`public function getRegion()\r\n   {\r\n       return $this->hasOne('App\\Regions','id','region_id');\r\n   }`\r\n\r\nAlthough not necessary I put in the fields in trying to get the datatable to work.\r\n\r\nso my table has the following javascript call (I have added buttons etc):\r\n\r\n`<script>\r\n    $(document).ready(function() {\r\n          $('#thetable').DataTable( {\r\n              dom: 'lBfrtip',\r\n                  \"iDisplayLength\": 25,\r\n                  \"lengthMenu\": [ [10, 25, 50, -1], [10, 25, 50, \"All\"] ],\r\n                  serverSide: true,\r\n                  processing: true,\r\n                  responsive: true,\r\n                  ajax: \"{{ route('advertisersLaratables') }}\",\r\n                  columns: [\r\n                    { name: 'firstname' },\r\n                    { name: 'surname' },\r\n                    { name: 'companyName' },\r\n                    { name: 'email' },\r\n                    { name: 'town' },\r\n                    { name: 'getRegion.region'}\r\n                ],\r\n\r\n                  columnDefs: [\r\n                     {'orderable':false, \"targets\":[3,4]    }\r\n                   ],\r\n                  buttons: [\r\n                     { extend:'copy',\r\n                           text: '<span style=\"color:darkblue\" title=\"copy\"><i class=\"fa fa-clone\"></i></span>',\r\n                      },\r\n                      {extend: 'print',\r\n                          title: 'Advertisers - <?php echo $today_f; ?>',\r\n                          text: '<span style=\"color:darkblue\" title=\"print\"><i class=\"fa fa-print\"></i></span>',\r\n                      },\r\n                      {extend: 'excel',\r\n                          filename: 'Advertisers - <?php echo $today_f; ?>',\r\n                         text: '<span style=\"color:darkblue\" title=\"Excel\"><i class=\"fa fa-file-excel\"></i></span>',\r\n                          footer:true,\r\n                      },\r\n                      {extend: 'pdf',\r\n                          filename:  'Advertisers - <?php echo $today_f; ?>',\r\n                          text: '<span style=\"color:darkblue\" title=\"pdf\"><i class=\"fa fa-file-pdf\"></i></span>',\r\n                      },\r\n                      {extend:'csvHtml5',\r\n                          filename: 'Advertisers - <?php echo $today_f; ?>',\r\n                          text: '<span style=\"color:darkblue\" title=\"csv\"><i class=\"fab fa-html5\" aria-hidden=\"true\"></i></span>',\r\n                      },\r\n                      {extend: 'collection',\r\n                          text:'<span style=\"color:darkblue\" title=\"show/hide columns \"><i class=\"fa fa-columns\"></i></span>',\r\n                          buttons:['columnsVisibility'] }\r\n                      ]\r\n          } );\r\n      } );\r\n\r\n\r\n    </script>`\r\n\r\nAlthough I have checked this with tinker etc I just get N/A for the region name.\r\n"},"comment":{"url":"https://api.github.com/repos/freshbitsweb/laratables/issues/comments/431666929","html_url":"https://github.com/freshbitsweb/laratables/issues/19#issuecomment-431666929","issue_url":"https://api.github.com/repos/freshbitsweb/laratables/issues/19","id":431666929,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTY2NjkyOQ==","user":{"login":"jim1506","id":123184,"node_id":"MDQ6VXNlcjEyMzE4NA==","avatar_url":"https://avatars1.githubusercontent.com/u/123184?v=4","gravatar_id":"","url":"https://api.github.com/users/jim1506","html_url":"https://github.com/jim1506","followers_url":"https://api.github.com/users/jim1506/followers","following_url":"https://api.github.com/users/jim1506/following{/other_user}","gists_url":"https://api.github.com/users/jim1506/gists{/gist_id}","starred_url":"https://api.github.com/users/jim1506/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jim1506/subscriptions","organizations_url":"https://api.github.com/users/jim1506/orgs","repos_url":"https://api.github.com/users/jim1506/repos","events_url":"https://api.github.com/users/jim1506/events{/privacy}","received_events_url":"https://api.github.com/users/jim1506/received_events","type":"User","site_admin":false},"created_at":"2018-10-21T13:02:29Z","updated_at":"2018-10-21T13:02:29Z","author_association":"NONE","body":"The relationship is:\r\n`\r\npublic function getRegion()\r\n   {\r\n       return $this->hasOne('App\\Regions','id','region_id');\r\n   }\r\n\r\nI have just run the following:\r\n\r\n`$advertisers = Advertiser::with('getRegion')->limit(10)->get();\r\ndd($advertisers;`\r\n\r\nand the relationship worked fine\r\n\r\n\r\n`"}}
{"actor":{"display_login":"jim1506"}}