Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function compileColumnExists() #80

Open
acidjazz opened this issue Jul 24, 2016 · 4 comments
Open

Call to a member function compileColumnExists() #80

acidjazz opened this issue Jul 24, 2016 · 4 comments

Comments

@acidjazz
Copy link

acidjazz commented Jul 24, 2016

Setup is the latest version of Lumen with mongodb.

I'm 99% sure I have everything setup right from your example and I get:

Fatal error: Call to a member function compileColumnExists() on null in /Users/k/opsis/vendor/illuminate/database/Schema/Builder.php on line 116

image

@nilportugues
Copy link
Owner

With this data it is impossible for me to determine what's wrong or if this is even an issue related to this library. I need context.

Some code + laravel-mongodb version + laravel5-jsonapi version, please?

@acidjazz
Copy link
Author

acidjazz commented Jul 24, 2016

Apologies,

laravel-mongodb version is v3.0
laravel5-jsonapi version is v2.4

Doing some research it seems as if null is being passed instead of a Grammar instance?

@acidjazz
Copy link
Author

acidjazz commented Jul 24, 2016

More details:

Lumen service provider include:

$app->register(\NilPortugues\Laravel5\JsonApi\Laravel5JsonApiServiceProvider::class);
$app->configure('jsonapi');

jsonapi configuration file

<?php

use App\Transformers\ItemTransformer;
return [ ItemTransformer::class, ];

routes.php

$app->get('/', ['as' => 'home', 'uses' => 'Home@index']);

$app->group(
  ['namespace' => 'App\Http\Controllers'], function($app) {
    $app->get(
      'items', [
      'as' => 'item.index',
      'uses' =>'ItemController@index'
    ]);
    $app->get(
      'item/{item_id}', [
      'as' => 'item.show', 
      'uses' =>'ItemController@show'
    ]);
  }
);

Transformer

<?php

namespace App\Transformers;

use App\Models\Item;
use NilPortugues\Api\Mappings\JsonApiMapping;

class ItemTransformer implements JsonApiMapping
{

  public function getClass() {
    return Item::class;
  }

  public function getAlias() {
    return 'item';
  }

  public function getAliasedProperties() {
    return [];
  }

  public function getHideProperties() {
    return [];
  }

  public function getIdProperties() {
    return ['id'];
  }

  public function getUrls() {
    return [
      'self' => ['name' => 'item.show', 'as_id' => 'id'],
      'items' => ['name' => 'item.index'],
      ];
  }

  public function getRelationships() {
    return [];
  }

}

Controller

<?php

namespace App\Http\Controllers;

use App\Models\Item;
use NilPortugues\Laravel5\JsonApi\Controller\LumenJsonApiController;

class ItemController extends LumenJsonAPiController
{

  public function index() {
  }

  public function getdataModel() {
    return new Item();
  }

}

and my model

namespace App\Models;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Illuminate\Foundation\Validation\ValidatesRequests;

class Item extends Eloquent
{

  public $timestamps = false;
  protected $collection = 'item';
  protected $primaryKey = 'id';
  protected $appends = [];

  protected $dates = [
    'dates.created',
    'dates.updated'
  ];

  protected $fillable = [
    'title',
    'image',
    'creator',
    'subjects',
    'dates',
  ];
}

@nilportugues
Copy link
Owner

@acidjazz does this happen if you turn off or default non-dot field names for $dates?

I believe the problem on the lib is there from the code you posted. Just to make sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants