Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgmyr committed Feb 14, 2023
2 parents d19d3e3 + d9218bf commit 0a74f94
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/run-tests-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.1','8.0' ]
php-versions: [ '8.1', '8.0' ]
dependency-stability: [ prefer-stable ]

laravel: [ '9.*' ]
laravel: [ '10.*', '9.*' ]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 10.*
php-versions: 8.0

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/run-tests-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.1','8.0' ]
php-versions: [ '8.1', '8.0' ]
dependency-stability: [ prefer-stable ]

laravel: [ '9.*' ]
laravel: [ '10.*', '9.*']
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 10.*
php-versions: 8.0

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.1','8.0','7.4','7.3','7.2' ]
php-versions: [ '8.1', '8.0', '7.4', '7.3', '7.2' ]
dependency-stability: [ prefer-stable ]
laravel: [ '9.*','8.*','7.*','6.*' ]
laravel: [ '10.*', '9.*', '8.*', '7.*', '6.*' ]

include:
- laravel: 10.*
testbench: 8.*
dbal: ^3.1.2
- laravel: 9.*
testbench: 7.*
dbal: ^3.1.2
Expand All @@ -28,6 +31,14 @@ jobs:
testbench: 4.*
dbal: ^2.6
exclude:
- laravel: 10.*
php-versions: 8.0
- laravel: 10.*
php-versions: 7.4
- laravel: 10.*
php-versions: 7.3
- laravel: 10.*
php-versions: 7.2
- laravel: 9.*
php-versions: 7.2
- laravel: 9.*
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "cmgmyr/messenger",
"description": "Simple user messaging tool for Laravel",
"keywords": ["laravel", "messenger", "messaging", "user messaging"],
"keywords": [
"laravel",
"messenger",
"messaging",
"user messaging"
],
"license": "MIT",
"authors": [
{
Expand All @@ -13,15 +18,15 @@
],
"require": {
"php": "^7.2|^8.0",
"illuminate/config": "^5.5|^6.0|^7.0|^8.0|^9.0",
"illuminate/database": "^5.5|^6.0|^7.0|^8.0|^9.0",
"illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0"
"illuminate/config": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0"
},
"require-dev": {
"doctrine/dbal": "^3.1.2|^2.13.3",
"fakerphp/faker": "^1.16",
"fakerphp/faker": "^1.16|^1.9.1",
"friendsofphp/php-cs-fixer": "^3.2|^2.18",
"orchestra/testbench": "^3.0|^4.0|^5.0|^6.0|^7.0",
"orchestra/testbench": "^3.0|^4.0|^5.0|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.0|^9.3.3"
},
"autoload": {
Expand Down
38 changes: 20 additions & 18 deletions src/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,13 @@ public function scopeForUserWithNewMessages(Builder $query, $userId)
*/
public function scopeBetweenOnly(Builder $query, array $participants)
{
return $query->whereHas('participants', function (Builder $builder) use ($participants) {
$participantTable = Models::table('participants');

return $query->whereHas('participants', function (Builder $builder) use ($participants, $participantTable) {
return $builder->whereIn('user_id', $participants)
->groupBy('participants.thread_id')
->select('participants.thread_id')
->havingRaw('COUNT(participants.thread_id)=?', [count($participants)]);
->groupBy($participantTable . '.thread_id')
->select($participantTable . '.thread_id')
->havingRaw('COUNT(' . $participantTable . '.thread_id)=?', [count($participants)]);
});
}

Expand Down Expand Up @@ -405,20 +407,20 @@ protected function createSelectString($columns)
$usersTable = Models::table('users');

switch ($dbDriver) {
case 'pgsql':
case 'sqlite':
$columnString = implode(" || ' ' || " . $tablePrefix . $usersTable . '.', $columns);
$selectString = '(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';

break;
case 'sqlsrv':
$columnString = implode(" + ' ' + " . $tablePrefix . $usersTable . '.', $columns);
$selectString = '(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';

break;
default:
$columnString = implode(", ' ', " . $tablePrefix . $usersTable . '.', $columns);
$selectString = 'concat(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';
case 'pgsql':
case 'sqlite':
$columnString = implode(" || ' ' || " . $tablePrefix . $usersTable . '.', $columns);
$selectString = '(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';

break;
case 'sqlsrv':
$columnString = implode(" + ' ' + " . $tablePrefix . $usersTable . '.', $columns);
$selectString = '(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';

break;
default:
$columnString = implode(", ' ', " . $tablePrefix . $usersTable . '.', $columns);
$selectString = 'concat(' . $tablePrefix . $usersTable . '.' . $columnString . ') as name';
}

return $selectString;
Expand Down

0 comments on commit 0a74f94

Please sign in to comment.