Skip to content

Commit

Permalink
Merge pull request #14 from ARCANEDEV/update-laravel_5.7_support
Browse files Browse the repository at this point in the history
Adding Laravel 5.7 support
  • Loading branch information
arcanedev-maroc authored Sep 6, 2018
2 parents 8fd3283 + b519938 commit 22f81d3
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This Laravel Messenger will allow you to add a messaging system into your Larave
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
* Laravel `5.1` to `5.7` are supported.
* Made with :heart: & :coffee:.

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

[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%205.6-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%205.7-orange.svg?style=flat-square
[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-messenger.svg?style=flat-square
[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelMessenger.svg?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelMessenger.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion _docs/0-Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This Laravel Messenger will allow you to add a messaging system into your Larave
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
* Laravel `5.1` to `5.7` are supported.
* Made with :heart: & :coffee:.

## Table of contents
Expand Down
3 changes: 3 additions & 0 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
| ![LaravelMessenger v2.x][laravel_messenger_2_x] | ![Laravel v5.4][laravel_5_4] |
| ![LaravelMessenger v3.x][laravel_messenger_3_x] | ![Laravel v5.5][laravel_5_5] |
| ![LaravelMessenger v4.x][laravel_messenger_4_x] | ![Laravel v5.6][laravel_5_6] |
| ![LaravelMessenger v5.x][laravel_messenger_5_x] | ![Laravel v5.7][laravel_5_7] |

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

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

## Composer

Expand Down
2 changes: 1 addition & 1 deletion _docs/2-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
2. [Configuration](2-Configuration.md)
3. [Usage](3-Usage.md)

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


```php
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"license": "MIT",
"require": {
"php": ">=7.1.3",
"arcanedev/support": "~4.3.0"
"arcanedev/support": "~4.4.0"
},
"require-dev": {
"orchestra/testbench": "~3.6.0",
"orchestra/testbench": "~3.7.0",
"mockery/mockery": "~1.1",
"phpunit/phpunit": "~7.0",
"phpunit/phpcov": "~5.0"
},
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
Expand All @@ -27,6 +26,6 @@
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-text" target="build/logs/coverage.txt"/>
<log type="coverage-html" target="build/logs/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/logs/coverage"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion src/LaravelMessengerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LaravelMessengerServiceProvider extends PackageServiceProvider
*
* @var string
*/
protected $package = 'laravel-messenger';
protected $package = 'messenger';

/* -----------------------------------------------------------------
| Main Methods
Expand Down
20 changes: 10 additions & 10 deletions src/Models/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Discussion extends Model implements DiscussionContract
public function __construct(array $attributes = [])
{
$this->setTable(
config('laravel-messenger.discussions.table', 'discussions')
config('messenger.discussions.table', 'discussions')
);

parent::__construct($attributes);
Expand All @@ -102,7 +102,7 @@ public function __construct(array $attributes = [])
public function participations()
{
return $this->hasMany(
config('laravel-messenger.participations.model', Participation::class)
config('messenger.participations.model', Participation::class)
);
}

Expand All @@ -114,7 +114,7 @@ public function participations()
public function messages()
{
return $this->hasMany(
config('laravel-messenger.messages.model', Message::class)
config('messenger.messages.model', Message::class)
);
}

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

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

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

foreach ($participables as $participable) {
Expand Down Expand Up @@ -257,7 +257,7 @@ public function getLatestMessageAttribute()
*/
protected function getParticipationsTable()
{
return config('laravel-messenger.participations.table', 'participations');
return config('messenger.participations.table', 'participations');
}

/* -----------------------------------------------------------------
Expand Down Expand Up @@ -315,7 +315,7 @@ public function getParticipables()
*/
public function addParticipant(EloquentModel $participable)
{
$morph = config('laravel-messenger.users.morph', 'participable');
$morph = config('messenger.users.morph', 'participable');

return $this->participations()->firstOrCreate([
"{$morph}_id" => $participable->getKey(),
Expand Down Expand Up @@ -363,7 +363,7 @@ public function removeParticipant(EloquentModel $participable, $reload = true)
*/
public function removeParticipants($participables, $reload = true)
{
$morph = config('laravel-messenger.users.morph', 'participable');
$morph = config('messenger.users.morph', 'participable');
$deleted = 0;

foreach ($participables as $participable) {
Expand Down Expand Up @@ -420,7 +420,7 @@ public function isUnread(EloquentModel $participable)
*/
public function getParticipationByParticipable(EloquentModel $participable)
{
$morph = config('laravel-messenger.users.morph', 'participable');
$morph = config('messenger.users.morph', 'participable');

return $this->participations()
->where("{$morph}_type", '=', $participable->getMorphClass())
Expand Down Expand Up @@ -491,7 +491,7 @@ public function participationsString($callback = null, $glue = ', ')
*/
public function hasParticipation(EloquentModel $participable)
{
$morph = config('laravel-messenger.users.morph', 'participable');
$morph = config('messenger.users.morph', 'participable');

return $this->participations()
->where("{$morph}_id", '=', $participable->getKey())
Expand Down
13 changes: 8 additions & 5 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class Message extends Model implements MessageContract
*
* @var array
*/
protected $fillable = ['discussion_id', 'body'];
protected $fillable = [
'discussion_id',
'body',
];

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

parent::__construct($attributes);
Expand All @@ -86,7 +89,7 @@ public function __construct(array $attributes = [])
public function discussion()
{
return $this->belongsTo(
config('laravel-messenger.discussions.model', Discussion::class)
config('messenger.discussions.model', Discussion::class)
);
}

Expand Down Expand Up @@ -118,7 +121,7 @@ public function participable()
public function participations()
{
return $this->hasMany(
config('laravel-messenger.participations.model', Participation::class),
config('messenger.participations.model', Participation::class),
'discussion_id',
'discussion_id'
);
Expand All @@ -136,7 +139,7 @@ public function participations()
*/
public function getRecipientsAttribute()
{
$morph = config('laravel-messenger.users.morph', 'participable');
$morph = config('messenger.users.morph', 'participable');

return $this->participations->reject(function (Participation $participant) use ($morph) {
return $participant->getAttribute("{$morph}_id") === $this->getAttribute("{$morph}_id")
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ abstract class Model extends BaseModel
public function __construct(array $attributes = [])
{
$this->setConnection(
config('laravel-messenger.database.connection')
config('messenger.database.connection')
);
$this->setPrefix(
config('laravel-messenger.database.prefix')
config('messenger.database.prefix')
);

parent::__construct($attributes);
Expand Down
11 changes: 8 additions & 3 deletions src/Models/Participation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ class Participation extends Model implements ParticipantContract
*
* @var array
*/
protected $fillable = ['discussion_id', 'participable_type', 'participable_id', 'last_read'];
protected $fillable = [
'discussion_id',
'participable_type',
'participable_id',
'last_read',
];

/**
* The attributes that should be mutated to dates.
Expand Down Expand Up @@ -72,7 +77,7 @@ class Participation extends Model implements ParticipantContract
public function __construct(array $attributes = [])
{
$this->setTable(
config('laravel-messenger.participations.table', 'participations')
config('messenger.participations.table', 'participations')
);

parent::__construct($attributes);
Expand All @@ -91,7 +96,7 @@ public function __construct(array $attributes = [])
public function discussion()
{
return $this->belongsTo(
config('laravel-messenger.discussions.model', Discussion::class)
config('messenger.discussions.model', Discussion::class)
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/Traits/Messagable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ trait Messagable
public function discussions()
{
return $this->morphToMany(
config("laravel-messenger.discussions.model", Models\Discussion::class),
config("laravel-messenger.users.morph", 'participable'),
config("laravel-messenger.participations.table", 'participations')
config('messenger.discussions.model', Models\Discussion::class),
config('messenger.users.morph', 'participable'),
config('messenger.participations.table', 'participations')
);
}

Expand All @@ -43,8 +43,8 @@ public function discussions()
public function participations()
{
return $this->morphMany(
config("laravel-messenger.participations.model", Models\Participation::class),
config("laravel-messenger.users.morph", 'participable')
config('messenger.participations.model', Models\Participation::class),
config('messenger.users.morph', 'participable')
);
}

Expand All @@ -56,8 +56,8 @@ public function participations()
public function messages()
{
return $this->morphMany(
config("laravel-messenger.messages.model", Models\Message::class),
config("laravel-messenger.users.morph", 'participable')
config('messenger.messages.model', Models\Message::class),
config('messenger.users.morph', 'participable')
);
}

Expand All @@ -83,8 +83,8 @@ public function newMessagesCount()
*/
public function discussionsWithNewMessages()
{
$participationsTable = config("laravel-messenger.participations.table", 'participations');
$discussionsTable = config("laravel-messenger.discussions.table", 'discussions');
$participationsTable = config('messenger.participations.table', 'participations');
$discussionsTable = config('messenger.discussions.table', 'discussions');

return $this->discussions()->where(function (Builder $query) use ($participationsTable, $discussionsTable) {
$query->whereNull("$participationsTable.last_read");
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('auth.model', Stubs\Models\User::class);

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

/**
Expand Down

0 comments on commit 22f81d3

Please sign in to comment.