Giter Site home page Giter Site logo

laravel-ddd's People

Contributors

mohammadmehrabani avatar orphail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-ddd's Issues

Suggestions and questions

  1. Why aren't you using the spatie/laravel-data package?
  2. In which layer should form requests be placed?

Where to put logic that is needed by queries and commands

As far as I understood the docs there is no place (yet) where I can but logic that is needed by both. E.g. I have a rule that a user can add post on specific conditions. This is relevant for the command. But I also have a button to add a post. I want this button to be shown only when the user is allowed to do so.
Where can I put these shared rules? What is your recommendation?

Thank you in advance.

Failed tests

Describe the bug

The test for the automatic creation of database didn't complete successfully.
Tests: 4 failed, 42 passed (221 assertions)

Theses failed tests are as follows:

FAIL Tests\Feature\CompanyTest
⨯ can add a department to a company
⨯ can update a department from a company
⨯ can delete a department from a company
FAIL Tests\Feature\UserTest
⨯ admin can create a user

To Reproduce

(1) composer install
(2) cp .env.example .env
(3) php artisan key:generate
(4) php artisan jwt:secret
(5) php artisan test

Expected behavior

I was expecting to see the following tables ( in my mysql database) populated:
companies
company_addresses
company_contacts
company_departments
password_reset_tokens
personal_access_tokens
users

Screenshots/Video

image

image

image

image

image

Desktop

  • OS: ubuntu 22.04
  • Browser: chrome, edge

Additional context

What is suppose to happen after a successful completion of the test?
Why don't you have a views folder with a blade template to show any data to user?

How to populate the DB tables

Describe the bug

I have been trying to populate the DB tables with data.
Upon global search in my VS Code I found out you have a setting seeder class Database\Seeders\DatabaseSeeder.
This class seems to add default configuration to a User database table via the model \App\Models\User.

The namespace \App\Models, however, does not exist . In your README file you explained why you purposefully avoided using the app/ folder ( as is usually the case in Laravel project setting) in order to stress the DDD methodology and hence make a difference to laravel's principle. Instead you mentioned to have opted for the src/ folder. Hence, it makes sense to me why the namespace \App\Models is used nowhere in the laravel-ddd project.

So then the question remain: how to you populate the tables.
Do I use the following namespaces to populate the DB tables ?
(1) Src\Agenda\User\Infrastructure\EloquentModels
(2) Src\Agenda\Company\Infrastructure\EloquentModels

Also what about the following namespace:
(1) Src\Auth\Application\Infrastructure
It doesn't have any EloquentModels. Is it because the class Src\Auth\Application\JWTAuth (which implements the interface Src\Auth\Domain\AuthInterface) depends on the email credential of the class
Src\Agenda\User\Infrastructure\EloquentModels\UserEloquentModel to return a token which in turn is consumed by the Src\Auth\Presentation\HTTP\AuthController to respond with that token ?

If so then what do I do with that token ? Do I use that token for the internal api routing? Or do I pass that token on to a frontend framework of my preference in order for that framework to gain access to the data availble in the laravel-ddd project ?

To Reproduce

Expected behavior

Inside the class Database\Seeders\DatabaseSeeder I want to invoke the method call() multiple times for each seeder class like for example :
$this->call(UserSeeder::class);
That way I can run all listed seeder classes at once with the command: $php artisan db:seed

This way of listing the seeder classes will require me to create those seeder classes in the first place.
Should I proceed on creating a seeder for each of the Models in the project?

Screenshots/Video

image

image

image

image

Desktop

  • OS: Ubuntu 20.04
  • Browser: chrome, edge

Additional context

Last question, in class Database\Factories\UserFactory you have commented out the following:
\Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>

what has that got to do with the class UserFactory? Here again you mention the namespace \App\Models\User.

Variable probably undefined in Repositories

In my search, I came across this repository, which offers excellent DDD interpretation and a solid starting point.
However, I discovered that in some Repositories classes, the upsertAll method could involve variables that are not defined.
For instance, in the code below, addressEloquent will be undefined if the company does not possess any addresses, which will prevent the execution of any further code.

public function upsertAll(Company $company): Address
{
foreach ($company->addresses as $address) {
$addressEloquent = AddressMapper::toEloquent($address);
$addressEloquent->company_id = $company->id;
$addressEloquent->save();
}
return AddressMapper::fromEloquent($addressEloquent);

I was unable to successfully integrate static analysis tools because of this.
Have you had the opportunity to address this? similar to including conditions or exceptions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.