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

#38 - Extend eloquent tools #42

Merged
merged 12 commits into from
Jun 28, 2024
Merged

#38 - Extend eloquent tools #42

merged 12 commits into from
Jun 28, 2024

Conversation

PiotrFedak
Copy link
Contributor

@PiotrFedak PiotrFedak commented Jun 7, 2024

This PR adds new functions to the eloquent trait.

  • Creates a model if it does not exist as data.
  • Creates the specified number of models if they are missing.
  • Checking relationships between models.

This should close #38

@PiotrFedak PiotrFedak changed the title model relations tools added #38 - Extend eloquent tools Jun 7, 2024
@PiotrFedak PiotrFedak marked this pull request as ready for review June 10, 2024 06:34
src/Features/Traits/Eloquent.php Outdated Show resolved Hide resolved
src/Features/Traits/Eloquent.php Outdated Show resolved Hide resolved
src/Features/Traits/Eloquent.php Outdated Show resolved Hide resolved
{
$modelClass = $this->recognizeModelClass($model);
$attributes = $table ? $table->getRowsHash() : [];

$modelClass::factory()->create($attributes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add creating for models without factory?

"The model $model1 does not have a $relation relation method.",
);

LaravelRelations::assertRelation($instance, $relation, 'Illuminate\Database\Eloquent\Relations\HasMany');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at this file: https://github.com/blumilksoftware/blt/blob/main/src/LaravelContracts.php and try to replicate its purpose here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, i think

src/Features/Traits/Eloquent.php Outdated Show resolved Hide resolved
src/Helpers/LaravelRelations.php Outdated Show resolved Hide resolved
@PiotrFedak PiotrFedak marked this pull request as draft June 24, 2024 10:00
@PiotrFedak PiotrFedak marked this pull request as draft June 25, 2024 08:32
@PiotrFedak PiotrFedak marked this pull request as ready for review June 25, 2024 10:21
@JakubKermes JakubKermes merged commit 18d2381 into main Jun 28, 2024
4 checks passed
@JakubKermes JakubKermes deleted the #38-Extend-eloquent-tools branch June 28, 2024 11:49
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

Successfully merging this pull request may close these issues.

Extend eloquent tools
4 participants