iamyojimbo
iamyojimbo

Reputation: 4679

Add Class to Laravel 4 Package

I am using this Laravel 4 package for interacting with the Xero accounting application: https://github.com/Daursu/xero

In the GitHub README, it says that you can extend the package easily by using the following code:

namespace Daursu\Xero;

class CreditNote extends BaseModel {

    /**
     * The name of the primary column.
     *
     * @var string
     */
    protected $primary_column = 'CreditNoteID';
}

I tried adding this as a new Model, but Laravel gives me a Class not found error.

I'm assuming this is a namespacing issue a but can't seem to get it right. I have tried using \Darsu\Xero and also \Darsu\Xero\BaseModel, and other various combinations with and without the initial \.

Any tips on how to do this right?

Upvotes: 0

Views: 79

Answers (1)

Mysteryos
Mysteryos

Reputation: 5791

Easiest way to achieve your intentions:

1) Create a file CreditNote.php in app\models

2) Put the following code in the above file:

use Daursu\Xero\BaseModel;

class CreditNote extends BaseModel {

    /**
     * The name of the primary column.
     *
     * @var string
     */
    protected $primary_column = 'CreditNoteID';
}

3) Whenever you need to use the CreditNote model, use $creditNote = new CreditNote();

Upvotes: 2

Related Questions