mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add mention model/migration/translation
This commit is contained in:
parent
86efcceb4c
commit
33ff1f7829
3 changed files with 68 additions and 0 deletions
33
app/Mention.php
Normal file
33
app/Mention.php
Normal 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');
|
||||
}
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
}
|
|
@ -5,5 +5,6 @@ return [
|
|||
'likedPhoto' => 'liked your photo.',
|
||||
'startedFollowingYou' => 'started following you.',
|
||||
'commented' => 'commented on your post.',
|
||||
'mentionedYou' => 'mentioned you.'
|
||||
|
||||
];
|
Loading…
Reference in a new issue