Skip to content

Commit 4ba8e3a

Browse files
committed
Merge branch 'master' into v2
2 parents 8320099 + b7f205b commit 4ba8e3a

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed

src/MessengerServiceProvider.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MessengerServiceProvider extends ServiceProvider
1717
* @return void
1818
* @throws BindingResolutionException
1919
*/
20-
public function boot(): void
20+
public function boot()
2121
{
2222
$this->offerPublishing();
2323
$this->setMessengerModels();
@@ -29,7 +29,7 @@ public function boot(): void
2929
*
3030
* @return void
3131
*/
32-
public function register(): void
32+
public function register()
3333
{
3434
$this->configure();
3535
}
@@ -39,7 +39,7 @@ public function register(): void
3939
*
4040
* @return void
4141
*/
42-
protected function configure(): void
42+
protected function configure()
4343
{
4444
$this->mergeConfigFrom(
4545
__DIR__ . '/../config/config.php',
@@ -52,7 +52,7 @@ protected function configure(): void
5252
*
5353
* @return void
5454
*/
55-
protected function offerPublishing(): void
55+
protected function offerPublishing()
5656
{
5757
if ($this->app->runningInConsole()) {
5858
$this->publishes([
@@ -71,7 +71,7 @@ protected function offerPublishing(): void
7171
* @return void
7272
* @throws BindingResolutionException
7373
*/
74-
protected function setMessengerModels(): void
74+
protected function setMessengerModels()
7575
{
7676
$config = $this->app->make('config');
7777

@@ -92,7 +92,7 @@ protected function setMessengerModels(): void
9292
* @return void
9393
* @throws BindingResolutionException
9494
*/
95-
protected function setUserModel(): void
95+
protected function setUserModel()
9696
{
9797
$config = $this->app->make('config');
9898

src/Models/Message.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(array $attributes = [])
6060
*
6161
* @codeCoverageIgnore
6262
*/
63-
public function thread(): BelongsTo
63+
public function thread()
6464
{
6565
return $this->belongsTo(Models::classname(Thread::class), 'thread_id', 'id');
6666
}
@@ -72,7 +72,7 @@ public function thread(): BelongsTo
7272
*
7373
* @codeCoverageIgnore
7474
*/
75-
public function user(): BelongsTo
75+
public function user()
7676
{
7777
return $this->belongsTo(Models::user(), 'user_id');
7878
}
@@ -84,7 +84,7 @@ public function user(): BelongsTo
8484
*
8585
* @codeCoverageIgnore
8686
*/
87-
public function participants(): HasMany
87+
public function participants()
8888
{
8989
return $this->hasMany(Models::classname(Participant::class), 'thread_id', 'thread_id');
9090
}
@@ -94,7 +94,7 @@ public function participants(): HasMany
9494
*
9595
* @return HasMany
9696
*/
97-
public function recipients(): HasMany
97+
public function recipients()
9898
{
9999
return $this->participants()->where('user_id', '!=', $this->user_id);
100100
}
@@ -106,7 +106,7 @@ public function recipients(): HasMany
106106
* @param mixed $userId
107107
* @return Builder
108108
*/
109-
public function scopeUnreadForUser(Builder $query, $userId): Builder
109+
public function scopeUnreadForUser(Builder $query, $userId)
110110
{
111111
return $query->has('thread')
112112
->where('user_id', '!=', $userId)

src/Models/Models.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Models
3232
*
3333
* @param string $model
3434
*/
35-
public static function setMessageModel(string $model): void
35+
public static function setMessageModel($model)
3636
{
3737
static::$models[Message::class] = $model;
3838
}
@@ -42,7 +42,7 @@ public static function setMessageModel(string $model): void
4242
*
4343
* @param string $model
4444
*/
45-
public static function setParticipantModel(string $model): void
45+
public static function setParticipantModel($model)
4646
{
4747
static::$models[Participant::class] = $model;
4848
}
@@ -52,7 +52,7 @@ public static function setParticipantModel(string $model): void
5252
*
5353
* @param string $model
5454
*/
55-
public static function setThreadModel(string $model): void
55+
public static function setThreadModel($model)
5656
{
5757
static::$models[Thread::class] = $model;
5858
}
@@ -62,7 +62,7 @@ public static function setThreadModel(string $model): void
6262
*
6363
* @param string $model
6464
*/
65-
public static function setUserModel(string $model): void
65+
public static function setUserModel($model)
6666
{
6767
static::$models[self::$userModelLookupKey] = $model;
6868
}
@@ -72,7 +72,7 @@ public static function setUserModel(string $model): void
7272
*
7373
* @param array $map
7474
*/
75-
public static function setTables(array $map): void
75+
public static function setTables(array $map)
7676
{
7777
static::$tables = array_merge(static::$tables, $map);
7878
}
@@ -83,7 +83,7 @@ public static function setTables(array $map): void
8383
* @param string $table
8484
* @return string
8585
*/
86-
public static function table(string $table): string
86+
public static function table($table)
8787
{
8888
return static::$tables[$table] ?? $table;
8989
}
@@ -94,7 +94,7 @@ public static function table(string $table): string
9494
* @param string $model
9595
* @return string
9696
*/
97-
public static function classname(string $model): string
97+
public static function classname($model)
9898
{
9999
return static::$models[$model] ?? $model;
100100
}
@@ -138,7 +138,7 @@ public static function thread(array $attributes = [])
138138
* @param array $attributes
139139
* @return Model
140140
*/
141-
public static function user(array $attributes = []): Model
141+
public static function user(array $attributes = [])
142142
{
143143
return static::make(self::$userModelLookupKey, $attributes);
144144
}
@@ -150,7 +150,7 @@ public static function user(array $attributes = []): Model
150150
* @param array $attributes
151151
* @return Model
152152
*/
153-
protected static function make(string $model, array $attributes = []): Model
153+
protected static function make($model, array $attributes = [])
154154
{
155155
$model = static::classname($model);
156156

src/Models/Participant.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(array $attributes = [])
4848
*
4949
* @codeCoverageIgnore
5050
*/
51-
public function thread(): BelongsTo
51+
public function thread()
5252
{
5353
return $this->belongsTo(Models::classname(Thread::class), 'thread_id', 'id');
5454
}
@@ -60,7 +60,7 @@ public function thread(): BelongsTo
6060
*
6161
* @codeCoverageIgnore
6262
*/
63-
public function user(): BelongsTo
63+
public function user()
6464
{
6565
return $this->belongsTo(Models::user(), 'user_id');
6666
}

src/Models/Thread.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(array $attributes = [])
6666
*
6767
* @codeCoverageIgnore
6868
*/
69-
public function messages(): HasMany
69+
public function messages()
7070
{
7171
return $this->hasMany(Models::classname(Message::class), 'thread_id', 'id');
7272
}
@@ -88,7 +88,7 @@ public function getLatestMessageAttribute()
8888
*
8989
* @codeCoverageIgnore
9090
*/
91-
public function participants(): HasMany
91+
public function participants()
9292
{
9393
return $this->hasMany(Models::classname(Participant::class), 'thread_id', 'id');
9494
}
@@ -100,7 +100,7 @@ public function participants(): HasMany
100100
*
101101
* @codeCoverageIgnore
102102
*/
103-
public function users(): BelongsToMany
103+
public function users()
104104
{
105105
return $this->belongsToMany(Models::classname('User'), Models::table('participants'), 'thread_id', 'user_id');
106106
}
@@ -110,7 +110,7 @@ public function users(): BelongsToMany
110110
*
111111
* @return null|Models::user()|\Illuminate\Database\Eloquent\Model
112112
*/
113-
public function creator(): ?Eloquent
113+
public function creator()
114114
{
115115
if ($this->creatorCache === null) {
116116
$firstMessage = $this->messages()->withTrashed()->oldest()->first();
@@ -137,7 +137,7 @@ public static function getAllLatest()
137137
*
138138
* @return Collection|static[]
139139
*/
140-
public static function getBySubject(string $subject)
140+
public static function getBySubject($subject)
141141
{
142142
return static::where('subject', 'like', $subject)->get();
143143
}
@@ -149,7 +149,7 @@ public static function getBySubject(string $subject)
149149
*
150150
* @return array
151151
*/
152-
public function participantsUserIds($userId = null): array
152+
public function participantsUserIds($userId = null)
153153
{
154154
$users = $this->participants()->withTrashed()->select('user_id')->get()->map(function ($participant) {
155155
return $participant->user_id;
@@ -170,7 +170,7 @@ public function participantsUserIds($userId = null): array
170170
*
171171
* @return Builder
172172
*/
173-
public function scopeForUser(Builder $query, $userId): Builder
173+
public function scopeForUser(Builder $query, $userId)
174174
{
175175
$participantsTable = Models::table('participants');
176176
$threadsTable = Models::table('threads');
@@ -189,7 +189,7 @@ public function scopeForUser(Builder $query, $userId): Builder
189189
*
190190
* @return Builder
191191
*/
192-
public function scopeForUserWithNewMessages(Builder $query, $userId): Builder
192+
public function scopeForUserWithNewMessages(Builder $query, $userId)
193193
{
194194
$participantTable = Models::table('participants');
195195
$threadsTable = Models::table('threads');
@@ -212,7 +212,7 @@ public function scopeForUserWithNewMessages(Builder $query, $userId): Builder
212212
*
213213
* @return Builder
214214
*/
215-
public function scopeBetweenOnly(Builder $query, array $participants): Builder
215+
public function scopeBetweenOnly(Builder $query, array $participants)
216216
{
217217
return $query->whereHas('participants', function (Builder $builder) use ($participants) {
218218
return $builder->whereIn('user_id', $participants)
@@ -230,7 +230,7 @@ public function scopeBetweenOnly(Builder $query, array $participants): Builder
230230
*
231231
* @return Builder
232232
*/
233-
public function scopeBetween(Builder $query, array $participants): Builder
233+
public function scopeBetween(Builder $query, array $participants)
234234
{
235235
return $query->whereHas('participants', function (Builder $q) use ($participants) {
236236
$q->whereIn('user_id', $participants)
@@ -247,7 +247,7 @@ public function scopeBetween(Builder $query, array $participants): Builder
247247
*
248248
* @return void
249249
*/
250-
public function addParticipant($userId): void
250+
public function addParticipant($userId)
251251
{
252252
$userIds = is_array($userId) ? $userId : func_get_args();
253253

@@ -266,7 +266,7 @@ public function addParticipant($userId): void
266266
*
267267
* @return void
268268
*/
269-
public function removeParticipant($userId): void
269+
public function removeParticipant($userId)
270270
{
271271
$userIds = is_array($userId) ? $userId : func_get_args();
272272

@@ -280,7 +280,7 @@ public function removeParticipant($userId): void
280280
*
281281
* @return void
282282
*/
283-
public function markAsRead($userId): void
283+
public function markAsRead($userId)
284284
{
285285
try {
286286
$participant = $this->getParticipantFromUser($userId);
@@ -298,7 +298,7 @@ public function markAsRead($userId): void
298298
*
299299
* @return bool
300300
*/
301-
public function isUnread($userId): bool
301+
public function isUnread($userId)
302302
{
303303
try {
304304
$participant = $this->getParticipantFromUser($userId);
@@ -333,7 +333,7 @@ public function getParticipantFromUser($userId)
333333
*
334334
* @return void
335335
*/
336-
public function activateAllParticipants(): void
336+
public function activateAllParticipants()
337337
{
338338
$participants = $this->participants()->onlyTrashed()->get();
339339
foreach ($participants as $participant) {
@@ -349,7 +349,7 @@ public function activateAllParticipants(): void
349349
*
350350
* @return string
351351
*/
352-
public function participantsString($userId = null, array $columns = ['name']): string
352+
public function participantsString($userId = null, $columns = ['name'])
353353
{
354354
$participantsTable = Models::table('participants');
355355
$usersTable = Models::table('users');
@@ -376,7 +376,7 @@ public function participantsString($userId = null, array $columns = ['name']): s
376376
*
377377
* @return bool
378378
*/
379-
public function hasParticipant($userId): bool
379+
public function hasParticipant($userId)
380380
{
381381
$participants = $this->participants()->where('user_id', '=', $userId);
382382

@@ -390,7 +390,7 @@ public function hasParticipant($userId): bool
390390
*
391391
* @return string
392392
*/
393-
protected function createSelectString(array $columns): string
393+
protected function createSelectString($columns)
394394
{
395395
$dbDriver = $this->getConnection()->getDriverName();
396396
$tablePrefix = $this->getConnection()->getTablePrefix();
@@ -423,7 +423,7 @@ protected function createSelectString(array $columns): string
423423
*
424424
* @return Collection
425425
*/
426-
public function userUnreadMessages($userId): Collection
426+
public function userUnreadMessages($userId)
427427
{
428428
$messages = $this->messages()->where('user_id', '!=', $userId)->get();
429429

@@ -449,7 +449,7 @@ public function userUnreadMessages($userId): Collection
449449
*
450450
* @return int
451451
*/
452-
public function userUnreadMessagesCount($userId): int
452+
public function userUnreadMessagesCount($userId)
453453
{
454454
return $this->userUnreadMessages($userId)->count();
455455
}

0 commit comments

Comments
 (0)