From 33ff1f7829aa5fc9b04f1f11c2dedd954dfd1a24 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 8 Jun 2018 21:05:13 -0600 Subject: [PATCH] Add mention model/migration/translation --- app/Mention.php | 33 ++++++++++++++++++ ...018_06_08_003624_create_mentions_table.php | 34 +++++++++++++++++++ resources/lang/en/notification.php | 1 + 3 files changed, 68 insertions(+) create mode 100644 app/Mention.php create mode 100644 database/migrations/2018_06_08_003624_create_mentions_table.php diff --git a/app/Mention.php b/app/Mention.php new file mode 100644 index 000000000..9600c32b0 --- /dev/null +++ b/app/Mention.php @@ -0,0 +1,33 @@ +belongsTo(Profile::class, 'profile_id', 'id'); + } + + public function status() + { + return $this->belongsTo(Status::class); + } + + public function toText() + { + $actorName = $this->status->profile->username; + return "{$actorName} " . __('notification.mentionedYou'); + } + + public function toHtml() + { + $actorName = $this->status->profile->username; + $actorUrl = $this->status->profile->url(); + return "{$actorName} " . + __('notification.mentionedYou'); + } +} diff --git a/database/migrations/2018_06_08_003624_create_mentions_table.php b/database/migrations/2018_06_08_003624_create_mentions_table.php new file mode 100644 index 000000000..2f43d1bae --- /dev/null +++ b/database/migrations/2018_06_08_003624_create_mentions_table.php @@ -0,0 +1,34 @@ +bigIncrements('id'); + $table->bigInteger('status_id')->unsigned(); + $table->bigInteger('profile_id')->unsigned(); + $table->boolean('local')->default(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('mentions'); + } +} diff --git a/resources/lang/en/notification.php b/resources/lang/en/notification.php index 2f85c4386..71d87a131 100644 --- a/resources/lang/en/notification.php +++ b/resources/lang/en/notification.php @@ -5,5 +5,6 @@ return [ 'likedPhoto' => 'liked your photo.', 'startedFollowingYou' => 'started following you.', 'commented' => 'commented on your post.', + 'mentionedYou' => 'mentioned you.' ]; \ No newline at end of file