Skip to content

Conversation

@nmc9
Copy link

@nmc9 nmc9 commented May 5, 2020

Except Method Added to HasAttributes class

I added an except method to \Illuminate\Database\Eloquent\Concerns\HasAttributes to compliment the only() method. For use on eloquent models

Use Case

This is useful for when you want to get most of the attributes of a model but not all of them in an array. It's the compliment to the only() method.

$stub = new StubModel();
$stub->only(["first_name","last_name"]);
$stub->except(["middle_name","updated_at","created_at"]);

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

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