ekmungai / eloquent-ifrs

Eloquent Double Entry Accounting with a focus on IFRS Compliant Reporting
MIT License
334 stars 68 forks source link

Auth::user()->entity returns Null #21

Closed AEK-BKF closed 3 years ago

AEK-BKF commented 3 years ago

Hello, I have issue when I create any record for Account, VAT, ... etc

auth()->user()->entity returns null

Laravel version 6.18.40 PHP version 7.4.10

Screenshot_2020-09-24 🧨 Trying to get property 'id' of non-object

ekmungai commented 3 years ago

Like the docs say, every object in the package must be associated with an entity. That means that before creating anything you must first create a entity object and associate it with the current logged in user.

AEK-BKF commented 3 years ago

Thanks for reply, Yes, I've already created the entity, currencies, vats, ..etc So, if I create new account like this :

$bankAccount = Account::create([
    'name' => "Sales Account",
    'account_type' => Account::BANK,
]);

It throws the error, Even if I do like this :

$bankAccount = Account::create([
    'name' => "Sales Account",
    'account_type' => Account::BANK,
    'currency_id' => $currency_id,
    'entity_id' => $entity_id,
]);
ekmungai commented 3 years ago

Verify two things:

  1. Is there a logged on user
  2. Is the logged on user associated with the entity you created
AEK-BKF commented 3 years ago

1- Yes 2- Yes

ekmungai commented 3 years ago

Then it must be an evironment issue, not a problem with the package itself. Try creating a new session and starting from scratch.

AEK-BKF commented 3 years ago

I'm really sorry, I deleted entity and create new one without assigning it to User.... Oh my Bad .... Sorry ....