Skip to content

Commit 1b888fc

Browse files
committed
rename newly added migration files
1 parent 51be475 commit 1b888fc

7 files changed

+17
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ object|false sendMessageByUserId($receiverId, $message)
294294

295295
### sendNotificationToUser
296296

297-
This allows you to quickly send notification to a user. Notifications usually will not have a sender (user), because the idea is that notifications are system messages (actions completed, alerts, etc.). However, Talk still allows you to specifier a sender if you must.
297+
This allows you to quickly send notification to a user.
298298

299299
**Syntax**
300300

database/migrations/2020_03_29_014907_make_user1_nullable_in_conversations_table.php renamed to database/migrations/2018_11_10_164802_add_title_column_to_conversations_table.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateConversationsTable extends Migration
7+
class AddTitleColumnToConversationsTable extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -14,7 +14,7 @@ class CreateConversationsTable extends Migration
1414
public function up()
1515
{
1616
Schema::table('conversations', function (Blueprint $table) {
17-
$table->integer('user_one')->nullable();
17+
$table->string('title');
1818
});
1919
}
2020

@@ -26,7 +26,7 @@ public function up()
2626
public function down()
2727
{
2828
Schema::table('conversations', function (Blueprint $table) {
29-
$table->integer('user_one');
29+
$table->dropColumn('title');
3030
});
3131
}
3232
}

database/migrations/2018_11_10_164802_add_title_column_to_messages_table.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

database/migrations/2018_11_10_160722_add_is_read_column_to_conversations_table.php renamed to database/migrations/2018_11_10_170722_add_is_read_column_to_conversations_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AddIsReadColumnToConversationsTable extends Migration
1414
public function up()
1515
{
1616
Schema::table('conversations', function (Blueprint $table) {
17-
$table->boolean('is_read')->default(0)->change();
17+
$table->boolean('is_read')->default(0);
1818
});
1919
}
2020

src/Talk.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ public function __construct(Repository $config, Broadcast $broadcast, Conversati
9898
* It returns an array whose elements are $user1 and $user2
9999
*
100100
* @param int $user1
101-
* @param int $user2
101+
* @param int $user2 This can be null in case of sending system notification
102102
*
103103
* @return array
104104
*/
105-
protected function getSerializeUser($user1_id, $user2_id)
105+
protected function getSerializeUser($user1_id, $user2_id = null)
106106
{
107-
$users = [];
108-
$user['one'] = ($user1_id < $user2_id) ? $user1_id : $user2_id;
109-
$user['two'] = ($user1_id < $user2_id) ? $user2_id : $user1_id;
107+
$users = [
108+
'one' => (($user1_id && $user1_id < $user2_id) ? $user1_id : $user2_id),
109+
'two' => (($user1_id && $user1_id < $user2_id) ? $user2_id : $user1_id),
110+
];
110111

111112
return $users;
112113
}
@@ -250,9 +251,9 @@ public function isConversationExists($userId)
250251
return false;
251252
}
252253

253-
$user = $this->getSerializeUser($this->authUserId, $userId);
254+
$users = $this->getSerializeUser($this->authUserId, $userId);
254255

255-
return $this->conversation->isExistsAmongTwoUsers($user['one'], $user['two']);
256+
return $this->conversation->isExistsAmongTwoUsers($users['one'], $users['two']);
256257
}
257258

258259
/**
@@ -324,15 +325,14 @@ public function sendMessageByUserId($receiverId, $message, $title = null, $tagNa
324325
* @param string $message
325326
* @param string $title
326327
* @param string $customNotificationTagName
327-
* @param int $optionalSenderId
328328
*
329329
* @return \Nahid\Talk\Messages\Message
330330
*/
331-
public function sendNotificationToUser($receiverId, $message, $title = null, $customNotificationTagName = null, $optionalSenderId = null)
331+
public function sendNotificationToUser($receiverId, $message, $title = null, $customNotificationTagName = null)
332332
{
333-
//when sending notifications, there is no user_one, because
334-
//notifications should ideally be sent by the "system"
335-
$this->authUserId = $optionalSenderId;
333+
if (is_null($this->authUserId)) {
334+
throw new \Exception("Authenticated user not found");
335+
}
336336

337337
$customNotificationTagName = empty($customNotificationTagName) ? self::NOTIFICATION_TAG : $customNotificationTagName;
338338

0 commit comments

Comments
 (0)