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

Add support to set machines in a model using machines() method. #82

Merged
merged 9 commits into from
Sep 4, 2024

Conversation

tkaratug
Copy link
Contributor

@tkaratug tkaratug commented Aug 5, 2024

This PR adds support to set machines via machines() method in a model in order to use expressions.

Scenario
Let's say we have a column for a machine root event in a table and we want to be able to use different machines based on a condition.

All we need to do is setting machines in machines() method instead of machines property.

protected $fillable = [
    ...
   'column_mre`
];

protected function machines(): array
{
    return [
        'column_mre' => match (true) {
            'condition A' => MachineA::class,
            'condition B' => MachineB::class,
        },
    ];
}

tkaratug and others added 2 commits August 5, 2024 17:03
This PR adds support to set machines via `machines()` method in a model in order to use expressions.
src/Traits/HasMachines.php Outdated Show resolved Hide resolved
@tkaratug
Copy link
Contributor Author

Hi Team,

I’m closing this PR because Laravel 11 introduced the ability to perform custom casting directly within the casts() method.

This new feature makes the changes proposed in this PR redundant, as the same functionality can now be achieved in a more integrated way within the framework.

@tkaratug tkaratug closed this Aug 12, 2024
@aydinfatih aydinfatih reopened this Sep 4, 2024
@deligoez deligoez merged commit f1f6ddf into main Sep 4, 2024
21 checks passed
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.

3 participants