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 model's withCount columns ot exempt attributes #17

Merged
merged 2 commits into from
Dec 3, 2018
Merged

Add model's withCount columns ot exempt attributes #17

merged 2 commits into from
Dec 3, 2018

Conversation

denitsa-md
Copy link
Contributor

@denitsa-md denitsa-md commented Dec 3, 2018

Pull request for #16 - exclude count columns from cloneable attributes

I wanted to ignore the count columns that also exist as explicitly set columns on the table by doing a diff (e.g. if a column randoms_count exists on the table and the column is also included in the $withCount = ['randoms'], it should still be included in the cloned attributes.)

But I'm not sure how to access the connection from inside the package.

$app['db'] inside Schema::connection() (facade) is NULL so I cannot call

Schema::connection($this->getConnection()->getName())->getColumnListing($this->getTable()) inside a function.

    private function getCountColumnsToExclude()
    {
        $count_columns = array_map(function($count_column) {
		    return $count_column . '_count';
        }, $this->withCount);

	return array_diff($count_columns, Schema::connection($this->getConnection()->getName())->getColumnListing($this->getTable()));
    }

@coveralls
Copy link

coveralls commented Dec 3, 2018

Coverage Status

Coverage increased (+0.3%) to 91.753% when pulling 23611b6 on SubscriptionPeople:Add-withCount-model-columns-to-exempt-columns into 14a36bd on BKWLD:master.

@weotch weotch merged commit fcfc302 into BKWLD:master Dec 3, 2018
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