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

refactor: rewrite model (MyModel and MyCRUD) #285

Merged
merged 26 commits into from
Mar 4, 2024

Conversation

SonyPradana
Copy link
Owner

@SonyPradana SonyPradana commented Feb 18, 2024

refactor model, combine MyModel and MYCRUD

MyCrud Capability


Api Name Supported Tested
getID ❌ but possible
setID ❌ multy id
setter ✔️ ✔️
getter ✔️ ✔️
__get ✔️ not recommend ✔️
__set ✔️ not recommend ✔️
read ✔️ ✔️
update ✔️ ✔️
delete ✔️ ✔️
isExist ✔️ ✔️
getLastInsertID
convertFromArray ❌ different name
convertToArray ✔️toArray instead ✔️
toCollection ❌ get instead
__isset
hasOne ✔️ ✔️
hasMany ✔️ ✔️
isClean ✔️ ✔️
isDearty ✔️ ✔️
13 13

MyModel Capability


API Name Supported Tested
setStrictSearch ✔️ deprecated ✔️
limitStart ✔️ deprecated ✔️
limitEnd ✔️ deprecated ✔️
order ✔️ deprecated ✔️
costumeWhere ✔️ ✔️
reset ✔️ ✔️
join ✔️ ✔️
getQuery ✔️
getWhere ✔️ ✔️
getMergeFilter
grupQueryFilter
queryFilter
queryBuilder
bindingFilter
single
result
resultAll
call**
select**
9 8

- Tests: 56, Assertions: 7, Skipped: 49
- Tests: 56, Assertions: 13, Skipped: 45.
- Tests: 56, Assertions: 17, Skipped: 42
- Tests: 56, Assertions: 22, Skipped: 37
- Tests: 58, Assertions: 30, Skipped: 32
- add costume where `Query::whereBinds`
- Tests: 59, Assertions: 33, Skipped: 30
- Tests: 60, Assertions: 34, Skipped: 30
- Tests: 67, Assertions: 66, Skipped: 11
@@ -0,0 +1,26 @@
<?php
Copy link
Owner Author

Choose a reason for hiding this comment

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

ambigus with original Collection, try to changes ModelCollection or other.

- `Collection` upstream update and delete
- add `Model::getPrimeryKey()`, `Model::isExist()`, `Model::findOrCreate`
- change visibility `Model::$where` to be `protected`
- 68 tests, 95 assertions
@SonyPradana
Copy link
Owner Author

finishing...
give method and parameters good documents

@SonyPradana SonyPradana marked this pull request as ready for review February 29, 2024 23:25
Copy link
Collaborator

@anggerpradana anggerpradana left a comment

Choose a reason for hiding this comment

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

better ux

/**
* @return CollectionImmutable<string, mixed>
*/
public function hasOne(string $table, string $ref = 'id')
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about return as model, and Model::class instead of table_nama

/**
* @return CollectionImmutable<string|int, mixed>
*/
public function hasMany(string $table, string $ref = 'id')
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about return as model, and Model::class instead of table_name

// private --------------------

/**
* Get column change status (compare with fresh record).
Copy link
Collaborator

Choose a reason for hiding this comment

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

reserves value

@SonyPradana SonyPradana merged commit 648161c into master Mar 4, 2024
8 checks passed
@SonyPradana SonyPradana deleted the refactor-database-model branch March 4, 2024 08:24
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.

2 participants