forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp#10571 Convert queries to eloquent
- Loading branch information
1 parent
0ce0834
commit 6d77552
Showing
5 changed files
with
152 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace PKP\emailTemplate; | ||
|
||
use Eloquence\Behaviours\HasCamelCasing; | ||
use Eloquence\Database\Model; | ||
use Illuminate\Contracts\Database\Eloquent\Builder; | ||
|
||
class EmailTemplateAccessGroup extends Model | ||
{ | ||
use HasCamelCasing; | ||
public $timestamps = false; | ||
protected $primaryKey = 'email_template_user_group_access_id'; | ||
protected $table = 'email_template_user_group_access'; | ||
protected $fillable = ['userGroupId', 'contextId','emailKey']; | ||
|
||
|
||
public function scopeWithEmailKey(Builder $query, ?array $keys): Builder | ||
{ | ||
return $query->when(!empty($keys), function ($query) use ($keys) { | ||
return $query->whereIn('email_key', $keys); | ||
}); | ||
} | ||
|
||
public function scopeWithContextId(Builder $query, int $contextId): Builder | ||
{ | ||
return $query->where('context_id', $contextId); | ||
} | ||
|
||
public function scopeWithGroupIds(Builder $query, array $ids): Builder | ||
{ | ||
return $query->whereIn('user_group_id', $ids); | ||
} | ||
} |
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