Add mention model/migration/translation

pull/168/merge
Daniel Supernault 2018-06-08 21:05:13 -06:00
rodzic 86efcceb4c
commit 33ff1f7829
3 zmienionych plików z 68 dodań i 0 usunięć

33
app/Mention.php 100644
Wyświetl plik

@ -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');
}
}

Wyświetl plik

@ -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');
}
}

Wyświetl plik

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