Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[4.0] Added hasScopes method. #70

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

Merged
yajra merged 1 commit into yajra:4.0 from alfa6661:features/has-scopes
Sep 5, 2018
Merged

[4.0] Added hasScopes method. #70

yajra merged 1 commit into yajra:4.0 from alfa6661:features/has-scopes
Sep 5, 2018

Conversation

@alfa6661
Copy link
Contributor

@alfa6661 alfa6661 commented Aug 23, 2018

I'm adding hasScopes method to check if the current DataTable class has the given scopes.
In my case, I have to determine the columns based on scopes. For example, it the DataTable class has a scope then I need to display A, B and C, otherwise display only A and B.

/**
 * Get columns.
 *
 * @return array
 */
protected function getColumns(): array
{
 $columns = [
 'A',
 'B',
 ];
 if ($this->hasScopes([MyScope::class])) {
 $columns = array_merge(
 $columns,
 [
 'C'
 ]
 );
 }
 return $columns;
}

I'm also adding a second parameter to the hasScopes method, it's a boolean flag (false by default) to set whether to check all the values for true, or to return true if at least one class is matched.

$this->hasScopes([FirstScope::class, SecondScope::class], true)

If we pas the second parameter true, we will check all the given query scopes for true, it means the DataTable class should have FirstScope and SecondScope class.

yajra reacted with thumbs up emoji
@yajra yajra changed the title (削除) added hasScopes method (削除ここまで) (追記) [4.0] Added hasScopes method. (追記ここまで) Sep 5, 2018
@yajra yajra merged commit 04fd0ed into yajra:4.0 Sep 5, 2018
Copy link
Owner

yajra commented Sep 5, 2018

Released on v4.2.0, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /