Skip to content
This repository was archived by the owner on May 12, 2024. It is now read-only.

feat: Improve the ORM #1

Open
Open
@pythonbrad

Description

@pythonbrad

Problem

The ORM don't permit to do some operations (will be describe below) directly in the database.
It's will be useful and better to be able to do it. Solve this problem, will also permit to replace the usage of special attributes who was a short-term solution.

Example

Count a set of objects

Before

count($question->answers);

Expected

$question->answers->count();

Verify if a set of objects exists

Before

if (count($question->answers)) {
   ...
}

Expected

if ($question->answers->exists()) {
  ...  
}

Delete a set of objects

Before

foreach ($question->answers as $answer) {
    $answer->delete();
}

Expected

$question->answers->delete();

Order a set of objects

Before

function score($quiz)
{
    return $quiz->score;
}
array_filter($user->quizzes, "score")

Expected

$user->quizzes->orderBy("score");

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions