aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/admin/src/Sprunje/UserSprunje.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/admin/src/Sprunje/UserSprunje.php')
-rw-r--r--main/app/sprinkles/admin/src/Sprunje/UserSprunje.php356
1 files changed, 178 insertions, 178 deletions
diff --git a/main/app/sprinkles/admin/src/Sprunje/UserSprunje.php b/main/app/sprinkles/admin/src/Sprunje/UserSprunje.php
index 0837912..a90eca3 100644
--- a/main/app/sprinkles/admin/src/Sprunje/UserSprunje.php
+++ b/main/app/sprinkles/admin/src/Sprunje/UserSprunje.php
@@ -1,178 +1,178 @@
-<?php
-/**
- * UserFrosting (http://www.userfrosting.com)
- *
- * @link https://github.com/userfrosting/UserFrosting
- * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
- */
-
-namespace UserFrosting\Sprinkle\Admin\Sprunje;
-
-use Illuminate\Database\Capsule\Manager as Capsule;
-use UserFrosting\Sprinkle\Core\Facades\Debug;
-use UserFrosting\Sprinkle\Core\Facades\Translator;
-use UserFrosting\Sprinkle\Core\Sprunje\Sprunje;
-
-/**
- * UserSprunje
- *
- * Implements Sprunje for the users API.
- *
- * @author Alex Weissman (https://alexanderweissman.com)
- */
-class UserSprunje extends Sprunje
-{
- protected $name = 'users';
-
- protected $listable = [
- 'status'
- ];
-
- protected $sortable = [
- 'name',
- 'last_activity',
- 'status'
- ];
-
- protected $filterable = [
- 'name',
- 'last_activity',
- 'status'
- ];
-
- protected $excludeForAll = [
- 'last_activity'
- ];
-
- /**
- * {@inheritDoc}
- */
- protected function baseQuery() {
- $query = $this->classMapper->createInstance('user');
-
- // Join user's most recent activity
- return $query->joinLastActivity()->with('lastActivity');
- }
-
- /**
- * Filter LIKE the last activity description.
- *
- * @param Builder $query
- * @param mixed $value
- * @return $this
- */
- protected function filterLastActivity($query, $value) {
- // Split value on separator for OR queries
- $values = explode($this->orSeparator, $value);
- $query->where(function ($query) use ($values) {
- foreach ($values as $value) {
- $query->orLike('activities.description', $value);
- }
- });
- return $this;
- }
-
- /**
- * Filter LIKE the first name, last name, or email.
- *
- * @param Builder $query
- * @param mixed $value
- * @return $this
- */
- protected function filterName($query, $value) {
- // Split value on separator for OR queries
- $values = explode($this->orSeparator, $value);
- $query->where(function ($query) use ($values) {
- foreach ($values as $value) {
- $query->orLike('first_name', $value)
- ->orLike('last_name', $value)
- ->orLike('email', $value);
- }
- });
- return $this;
- }
-
- /**
- * Filter by status (active, disabled, unactivated)
- *
- * @param Builder $query
- * @param mixed $value
- * @return $this
- */
- protected function filterStatus($query, $value) {
- // Split value on separator for OR queries
- $values = explode($this->orSeparator, $value);
- $query->where(function ($query) use ($values) {
- foreach ($values as $value) {
- if ($value == 'disabled') {
- $query->orWhere('flag_enabled', 0);
- } else if ($value == 'unactivated') {
- $query->orWhere('flag_verified', 0);
- } else if ($value == 'active') {
- $query->orWhere(function ($query) {
- $query->where('flag_enabled', 1)->where('flag_verified', 1);
- });
- }
- }
- });
- return $this;
- }
-
- /**
- * Return a list of possible user statuses.
- *
- * @return array
- */
- protected function listStatus() {
- return [
- [
- 'value' => 'active',
- 'text' => Translator::translate('ACTIVE')
- ],
- [
- 'value' => 'unactivated',
- 'text' => Translator::translate('UNACTIVATED')
- ],
- [
- 'value' => 'disabled',
- 'text' => Translator::translate('DISABLED')
- ]
- ];
- }
-
- /**
- * Sort based on last activity time.
- *
- * @param Builder $query
- * @param string $direction
- * @return $this
- */
- protected function sortLastActivity($query, $direction) {
- $query->orderBy('activities.occurred_at', $direction);
- return $this;
- }
-
- /**
- * Sort based on last name.
- *
- * @param Builder $query
- * @param string $direction
- * @return $this
- */
- protected function sortName($query, $direction) {
- $query->orderBy('last_name', $direction);
- return $this;
- }
-
- /**
- * Sort active, unactivated, disabled
- *
- * @param Builder $query
- * @param string $direction
- * @return $this
- */
- protected function sortStatus($query, $direction) {
- $query->orderBy('flag_enabled', $direction)->orderBy('flag_verified', $direction);
- return $this;
- }
-}
+<?php
+/**
+ * UserFrosting (http://www.userfrosting.com)
+ *
+ * @link https://github.com/userfrosting/UserFrosting
+ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
+ */
+
+namespace UserFrosting\Sprinkle\Admin\Sprunje;
+
+use Illuminate\Database\Capsule\Manager as Capsule;
+use UserFrosting\Sprinkle\Core\Facades\Debug;
+use UserFrosting\Sprinkle\Core\Facades\Translator;
+use UserFrosting\Sprinkle\Core\Sprunje\Sprunje;
+
+/**
+ * UserSprunje
+ *
+ * Implements Sprunje for the users API.
+ *
+ * @author Alex Weissman (https://alexanderweissman.com)
+ */
+class UserSprunje extends Sprunje
+{
+ protected $name = 'users';
+
+ protected $listable = [
+ 'status'
+ ];
+
+ protected $sortable = [
+ 'name',
+ 'last_activity',
+ 'status'
+ ];
+
+ protected $filterable = [
+ 'name',
+ 'last_activity',
+ 'status'
+ ];
+
+ protected $excludeForAll = [
+ 'last_activity'
+ ];
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function baseQuery() {
+ $query = $this->classMapper->createInstance('user');
+
+ // Join user's most recent activity
+ return $query->joinLastActivity()->with('lastActivity');
+ }
+
+ /**
+ * Filter LIKE the last activity description.
+ *
+ * @param Builder $query
+ * @param mixed $value
+ * @return $this
+ */
+ protected function filterLastActivity($query, $value) {
+ // Split value on separator for OR queries
+ $values = explode($this->orSeparator, $value);
+ $query->where(function ($query) use ($values) {
+ foreach ($values as $value) {
+ $query->orLike('activities.description', $value);
+ }
+ });
+ return $this;
+ }
+
+ /**
+ * Filter LIKE the first name, last name, or email.
+ *
+ * @param Builder $query
+ * @param mixed $value
+ * @return $this
+ */
+ protected function filterName($query, $value) {
+ // Split value on separator for OR queries
+ $values = explode($this->orSeparator, $value);
+ $query->where(function ($query) use ($values) {
+ foreach ($values as $value) {
+ $query->orLike('first_name', $value)
+ ->orLike('last_name', $value)
+ ->orLike('email', $value);
+ }
+ });
+ return $this;
+ }
+
+ /**
+ * Filter by status (active, disabled, unactivated)
+ *
+ * @param Builder $query
+ * @param mixed $value
+ * @return $this
+ */
+ protected function filterStatus($query, $value) {
+ // Split value on separator for OR queries
+ $values = explode($this->orSeparator, $value);
+ $query->where(function ($query) use ($values) {
+ foreach ($values as $value) {
+ if ($value == 'disabled') {
+ $query->orWhere('flag_enabled', 0);
+ } else if ($value == 'unactivated') {
+ $query->orWhere('flag_verified', 0);
+ } else if ($value == 'active') {
+ $query->orWhere(function ($query) {
+ $query->where('flag_enabled', 1)->where('flag_verified', 1);
+ });
+ }
+ }
+ });
+ return $this;
+ }
+
+ /**
+ * Return a list of possible user statuses.
+ *
+ * @return array
+ */
+ protected function listStatus() {
+ return [
+ [
+ 'value' => 'active',
+ 'text' => Translator::translate('ACTIVE')
+ ],
+ [
+ 'value' => 'unactivated',
+ 'text' => Translator::translate('UNACTIVATED')
+ ],
+ [
+ 'value' => 'disabled',
+ 'text' => Translator::translate('DISABLED')
+ ]
+ ];
+ }
+
+ /**
+ * Sort based on last activity time.
+ *
+ * @param Builder $query
+ * @param string $direction
+ * @return $this
+ */
+ protected function sortLastActivity($query, $direction) {
+ $query->orderBy('activities.occurred_at', $direction);
+ return $this;
+ }
+
+ /**
+ * Sort based on last name.
+ *
+ * @param Builder $query
+ * @param string $direction
+ * @return $this
+ */
+ protected function sortName($query, $direction) {
+ $query->orderBy('last_name', $direction);
+ return $this;
+ }
+
+ /**
+ * Sort active, unactivated, disabled
+ *
+ * @param Builder $query
+ * @param string $direction
+ * @return $this
+ */
+ protected function sortStatus($query, $direction) {
+ $query->orderBy('flag_enabled', $direction)->orderBy('flag_verified', $direction);
+ return $this;
+ }
+}