Skip to content

Commit

Permalink
Author search (#858)
Browse files Browse the repository at this point in the history
Initial Author Search feature
  • Loading branch information
vincentauger authored Dec 5, 2024
1 parent 0a8fb55 commit 7ab81b6
Show file tree
Hide file tree
Showing 25 changed files with 913 additions and 465 deletions.
18 changes: 18 additions & 0 deletions app/Models/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use App\Traits\HasExpertises;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -141,4 +142,21 @@ public function peerReviews(): HasMany
{
return $this->hasMany('App\Models\ManuscriptPeerReviewer');
}

public function scopeInternalAuthor(Builder $query): void
{
$Organization = Organization::getDefaultOrganization();
$query->where('organization_id', $Organization->id);
}

public function scopeExternalAuthor(Builder $query): void
{
$Organization = Organization::getDefaultOrganization();
$query->where('organization_id', '!=', $Organization->id);
}

public function scopeWithOrcid(Builder $query): void
{
$query->whereNotNull('orcid');
}
}
3 changes: 3 additions & 0 deletions app/Queries/AuthorListQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function __construct()
AllowedFilter::exact('organization_id'),
AllowedFilter::exact('orcid'),
AllowedFilter::custom('search', new FuzzyFilter('first_name', 'last_name', 'email')),
AllowedFilter::scope('internal_author'),
AllowedFilter::scope('external_author'),
AllowedFilter::scope('with_orcid'),
]);
}
}
Loading

0 comments on commit 7ab81b6

Please sign in to comment.