Add mention model/migration/translation

This commit is contained in:
Daniel Supernault 2018-06-08 21:05:13 -06:00
parent 86efcceb4c
commit 33ff1f7829
3 changed files with 68 additions and 0 deletions

33
app/Mention.php Normal file
View file

@ -0,0 +1,33 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Mention extends Model
{
public function profile()
{
return $this->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 "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> " .
__('notification.mentionedYou');
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMentionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('mentions', function (Blueprint $table) {
$table->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');
}
}

View file

@ -5,5 +5,6 @@ return [
'likedPhoto' => 'liked your photo.', 'likedPhoto' => 'liked your photo.',
'startedFollowingYou' => 'started following you.', 'startedFollowingYou' => 'started following you.',
'commented' => 'commented on your post.', 'commented' => 'commented on your post.',
'mentionedYou' => 'mentioned you.'
]; ];