Skip to content

Commit b519938

Browse files
Adding Laravel 5.7 support
+ Renaming the config file
1 parent 8fd3283 commit b519938

14 files changed

+50
-39
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This Laravel Messenger will allow you to add a messaging system into your Larave
2222
* Easy setup & configuration.
2323
* Well documented & IDE Friendly.
2424
* Well tested with maximum code quality.
25-
* Laravel `5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
25+
* Laravel `5.1` to `5.7` are supported.
2626
* Made with :heart: & :coffee:.
2727

2828
## Table of contents
@@ -45,7 +45,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.
4545
- [All Contributors][link-contributors]
4646
- [cmgmyr/laravel-messenger](https://github.com/cmgmyr/laravel-messenger)
4747

48-
[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%205.6-orange.svg?style=flat-square
48+
[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%205.7-orange.svg?style=flat-square
4949
[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-messenger.svg?style=flat-square
5050
[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelMessenger.svg?style=flat-square
5151
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelMessenger.svg?style=flat-square

_docs/0-Home.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This Laravel Messenger will allow you to add a messaging system into your Larave
88
* Easy setup & configuration.
99
* Well documented & IDE Friendly.
1010
* Well tested with maximum code quality.
11-
* Laravel `5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
11+
* Laravel `5.1` to `5.7` are supported.
1212
* Made with :heart: & :coffee:.
1313

1414
## Table of contents

_docs/1-Installation-and-Setup.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
| ![LaravelMessenger v2.x][laravel_messenger_2_x] | ![Laravel v5.4][laravel_5_4] |
1515
| ![LaravelMessenger v3.x][laravel_messenger_3_x] | ![Laravel v5.5][laravel_5_5] |
1616
| ![LaravelMessenger v4.x][laravel_messenger_4_x] | ![Laravel v5.6][laravel_5_6] |
17+
| ![LaravelMessenger v5.x][laravel_messenger_5_x] | ![Laravel v5.7][laravel_5_7] |
1718

1819
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
1920
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
2021
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
2122
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
2223
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
2324
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
25+
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
2426

2527
[laravel_messenger_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "LaravelMessenger v1.*"
2628
[laravel_messenger_2_x]: https://img.shields.io/badge/version-2.*-blue.svg?style=flat-square "LaravelMessenger v2.*"
2729
[laravel_messenger_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "LaravelMessenger v3.*"
2830
[laravel_messenger_4_x]: https://img.shields.io/badge/version-4.*-blue.svg?style=flat-square "LaravelMessenger v4.*"
31+
[laravel_messenger_5_x]: https://img.shields.io/badge/version-5.*-blue.svg?style=flat-square "LaravelMessenger v5.*"
2932

3033
## Composer
3134

_docs/2-Configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
2. [Configuration](2-Configuration.md)
77
3. [Usage](3-Usage.md)
88

9-
After you've published the config file `config/laravel-messenger.php`, you can customize the settings :
9+
After you've published the config file `config/messenger.php`, you can customize the settings :
1010

1111

1212
```php

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
"license": "MIT",
1818
"require": {
1919
"php": ">=7.1.3",
20-
"arcanedev/support": "~4.3.0"
20+
"arcanedev/support": "~4.4.0"
2121
},
2222
"require-dev": {
23-
"orchestra/testbench": "~3.6.0",
23+
"orchestra/testbench": "~3.7.0",
24+
"mockery/mockery": "~1.1",
2425
"phpunit/phpunit": "~7.0",
2526
"phpunit/phpcov": "~5.0"
2627
},
File renamed without changes.

phpunit.xml.dist

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<testsuites>
1413
<testsuite name="Package Test Suite">
@@ -27,6 +26,6 @@
2726
<logging>
2827
<log type="coverage-clover" target="build/logs/clover.xml"/>
2928
<log type="coverage-text" target="build/logs/coverage.txt"/>
30-
<log type="coverage-html" target="build/logs/coverage" charset="UTF-8" yui="true" highlight="true"/>
29+
<log type="coverage-html" target="build/logs/coverage"/>
3130
</logging>
3231
</phpunit>

src/LaravelMessengerServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LaravelMessengerServiceProvider extends PackageServiceProvider
2020
*
2121
* @var string
2222
*/
23-
protected $package = 'laravel-messenger';
23+
protected $package = 'messenger';
2424

2525
/* -----------------------------------------------------------------
2626
| Main Methods

src/Models/Discussion.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Discussion extends Model implements DiscussionContract
8383
public function __construct(array $attributes = [])
8484
{
8585
$this->setTable(
86-
config('laravel-messenger.discussions.table', 'discussions')
86+
config('messenger.discussions.table', 'discussions')
8787
);
8888

8989
parent::__construct($attributes);
@@ -102,7 +102,7 @@ public function __construct(array $attributes = [])
102102
public function participations()
103103
{
104104
return $this->hasMany(
105-
config('laravel-messenger.participations.model', Participation::class)
105+
config('messenger.participations.model', Participation::class)
106106
);
107107
}
108108

@@ -114,7 +114,7 @@ public function participations()
114114
public function messages()
115115
{
116116
return $this->hasMany(
117-
config('laravel-messenger.messages.model', Message::class)
117+
config('messenger.messages.model', Message::class)
118118
);
119119
}
120120

@@ -146,7 +146,7 @@ public function scopeForUser(Builder $query, EloquentModel $participable)
146146
$table = $this->getParticipationsTable();
147147

148148
return $query->join($table, function (JoinClause $join) use ($table, $participable) {
149-
$morph = config('laravel-messenger.users.morph', 'participable');
149+
$morph = config('messenger.users.morph', 'participable');
150150

151151
$join->on($this->getQualifiedKeyName(), '=', "{$table}.discussion_id")
152152
->where("{$table}.{$morph}_type", '=', $participable->getMorphClass())
@@ -201,7 +201,7 @@ public function scopeForUserWithNewMessages(Builder $query, EloquentModel $parti
201201
public function scopeBetween(Builder $query, $participables)
202202
{
203203
return $query->whereHas($this->getParticipationsTable(), function (Builder $query) use ($participables) {
204-
$morph = config('laravel-messenger.users.morph', 'participable');
204+
$morph = config('messenger.users.morph', 'participable');
205205
$index = 0;
206206

207207
foreach ($participables as $participable) {
@@ -257,7 +257,7 @@ public function getLatestMessageAttribute()
257257
*/
258258
protected function getParticipationsTable()
259259
{
260-
return config('laravel-messenger.participations.table', 'participations');
260+
return config('messenger.participations.table', 'participations');
261261
}
262262

263263
/* -----------------------------------------------------------------
@@ -315,7 +315,7 @@ public function getParticipables()
315315
*/
316316
public function addParticipant(EloquentModel $participable)
317317
{
318-
$morph = config('laravel-messenger.users.morph', 'participable');
318+
$morph = config('messenger.users.morph', 'participable');
319319

320320
return $this->participations()->firstOrCreate([
321321
"{$morph}_id" => $participable->getKey(),
@@ -363,7 +363,7 @@ public function removeParticipant(EloquentModel $participable, $reload = true)
363363
*/
364364
public function removeParticipants($participables, $reload = true)
365365
{
366-
$morph = config('laravel-messenger.users.morph', 'participable');
366+
$morph = config('messenger.users.morph', 'participable');
367367
$deleted = 0;
368368

369369
foreach ($participables as $participable) {
@@ -420,7 +420,7 @@ public function isUnread(EloquentModel $participable)
420420
*/
421421
public function getParticipationByParticipable(EloquentModel $participable)
422422
{
423-
$morph = config('laravel-messenger.users.morph', 'participable');
423+
$morph = config('messenger.users.morph', 'participable');
424424

425425
return $this->participations()
426426
->where("{$morph}_type", '=', $participable->getMorphClass())
@@ -491,7 +491,7 @@ public function participationsString($callback = null, $glue = ', ')
491491
*/
492492
public function hasParticipation(EloquentModel $participable)
493493
{
494-
$morph = config('laravel-messenger.users.morph', 'participable');
494+
$morph = config('messenger.users.morph', 'participable');
495495

496496
return $this->participations()
497497
->where("{$morph}_id", '=', $participable->getKey())

src/Models/Message.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ class Message extends Model implements MessageContract
4141
*
4242
* @var array
4343
*/
44-
protected $fillable = ['discussion_id', 'body'];
44+
protected $fillable = [
45+
'discussion_id',
46+
'body',
47+
];
4548

4649
/**
4750
* The attributes that should be cast to native types.
@@ -67,7 +70,7 @@ class Message extends Model implements MessageContract
6770
public function __construct(array $attributes = [])
6871
{
6972
$this->setTable(
70-
config('laravel-messenger.messeges.table', 'messages')
73+
config('messenger.messeges.table', 'messages')
7174
);
7275

7376
parent::__construct($attributes);
@@ -86,7 +89,7 @@ public function __construct(array $attributes = [])
8689
public function discussion()
8790
{
8891
return $this->belongsTo(
89-
config('laravel-messenger.discussions.model', Discussion::class)
92+
config('messenger.discussions.model', Discussion::class)
9093
);
9194
}
9295

@@ -118,7 +121,7 @@ public function participable()
118121
public function participations()
119122
{
120123
return $this->hasMany(
121-
config('laravel-messenger.participations.model', Participation::class),
124+
config('messenger.participations.model', Participation::class),
122125
'discussion_id',
123126
'discussion_id'
124127
);
@@ -136,7 +139,7 @@ public function participations()
136139
*/
137140
public function getRecipientsAttribute()
138141
{
139-
$morph = config('laravel-messenger.users.morph', 'participable');
142+
$morph = config('messenger.users.morph', 'participable');
140143

141144
return $this->participations->reject(function (Participation $participant) use ($morph) {
142145
return $participant->getAttribute("{$morph}_id") === $this->getAttribute("{$morph}_id")

src/Models/Model.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ abstract class Model extends BaseModel
2323
public function __construct(array $attributes = [])
2424
{
2525
$this->setConnection(
26-
config('laravel-messenger.database.connection')
26+
config('messenger.database.connection')
2727
);
2828
$this->setPrefix(
29-
config('laravel-messenger.database.prefix')
29+
config('messenger.database.prefix')
3030
);
3131

3232
parent::__construct($attributes);

src/Models/Participation.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ class Participation extends Model implements ParticipantContract
3939
*
4040
* @var array
4141
*/
42-
protected $fillable = ['discussion_id', 'participable_type', 'participable_id', 'last_read'];
42+
protected $fillable = [
43+
'discussion_id',
44+
'participable_type',
45+
'participable_id',
46+
'last_read',
47+
];
4348

4449
/**
4550
* The attributes that should be mutated to dates.
@@ -72,7 +77,7 @@ class Participation extends Model implements ParticipantContract
7277
public function __construct(array $attributes = [])
7378
{
7479
$this->setTable(
75-
config('laravel-messenger.participations.table', 'participations')
80+
config('messenger.participations.table', 'participations')
7681
);
7782

7883
parent::__construct($attributes);
@@ -91,7 +96,7 @@ public function __construct(array $attributes = [])
9196
public function discussion()
9297
{
9398
return $this->belongsTo(
94-
config('laravel-messenger.discussions.model', Discussion::class)
99+
config('messenger.discussions.model', Discussion::class)
95100
);
96101
}
97102

src/Traits/Messagable.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ trait Messagable
2929
public function discussions()
3030
{
3131
return $this->morphToMany(
32-
config("laravel-messenger.discussions.model", Models\Discussion::class),
33-
config("laravel-messenger.users.morph", 'participable'),
34-
config("laravel-messenger.participations.table", 'participations')
32+
config('messenger.discussions.model', Models\Discussion::class),
33+
config('messenger.users.morph', 'participable'),
34+
config('messenger.participations.table', 'participations')
3535
);
3636
}
3737

@@ -43,8 +43,8 @@ public function discussions()
4343
public function participations()
4444
{
4545
return $this->morphMany(
46-
config("laravel-messenger.participations.model", Models\Participation::class),
47-
config("laravel-messenger.users.morph", 'participable')
46+
config('messenger.participations.model', Models\Participation::class),
47+
config('messenger.users.morph', 'participable')
4848
);
4949
}
5050

@@ -56,8 +56,8 @@ public function participations()
5656
public function messages()
5757
{
5858
return $this->morphMany(
59-
config("laravel-messenger.messages.model", Models\Message::class),
60-
config("laravel-messenger.users.morph", 'participable')
59+
config('messenger.messages.model', Models\Message::class),
60+
config('messenger.users.morph', 'participable')
6161
);
6262
}
6363

@@ -83,8 +83,8 @@ public function newMessagesCount()
8383
*/
8484
public function discussionsWithNewMessages()
8585
{
86-
$participationsTable = config("laravel-messenger.participations.table", 'participations');
87-
$discussionsTable = config("laravel-messenger.discussions.table", 'discussions');
86+
$participationsTable = config('messenger.participations.table', 'participations');
87+
$discussionsTable = config('messenger.discussions.table', 'discussions');
8888

8989
return $this->discussions()->where(function (Builder $query) use ($participationsTable, $discussionsTable) {
9090
$query->whereNull("$participationsTable.last_read");

tests/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function getEnvironmentSetUp($app)
7676
$app['config']->set('auth.model', Stubs\Models\User::class);
7777

7878
// Laravel Messenger Configs
79-
$app['config']->set('laravel-messenger.users.model', Stubs\Models\User::class);
79+
$app['config']->set('messenger.users.model', Stubs\Models\User::class);
8080
}
8181

8282
/**

0 commit comments

Comments
 (0)