-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #10158 Move categoryids out of of publication_settings * #10158 Improve publication category handling and optimize query structure * #10158 Updated copyright and queries
- Loading branch information
1 parent
9ca4c44
commit 01210c2
Showing
7 changed files
with
89 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* @file classes/publication/PublicationCategory.php | ||
* | ||
* Copyright (c) 2024 Simon Fraser University | ||
* Copyright (c) 2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class PublicationCategory | ||
* | ||
* @brief Handles operations related to publication categories | ||
*/ | ||
|
||
namespace PKP\publication; | ||
|
||
use Eloquence\Behaviours\HasCamelCasing; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class PublicationCategory extends Model | ||
{ | ||
use HasCamelCasing; | ||
|
||
protected $table = 'publication_categories'; | ||
protected $primaryKey = 'publication_category_id'; | ||
public $timestamps = false; | ||
|
||
protected $fillable = [ | ||
'publication_id', 'category_id' | ||
]; | ||
|
||
/** | ||
* Scope a query to only include records with a specific publicationId | ||
*/ | ||
public function scopeWithPublicationId(Builder $query, int $publicationId): Builder | ||
{ | ||
return $query->where('publication_id', $publicationId); | ||
} | ||
|
||
/** | ||
* Scope a query to only include records with specific categoryIds | ||
* | ||
* @param int[] $categoryIds Array of category IDs | ||
*/ | ||
public function scopeWithCategoryIds(Builder $query, array $categoryIds): Builder | ||
{ | ||
return $query->whereIn('category_id', $categoryIds); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters