mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
lang
This commit is contained in:
40
app/Console/Commands/Database/FillUserEmails.php
Normal file
40
app/Console/Commands/Database/FillUserEmails.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Database;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FillUserEmails extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'users:emails';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$users = User::all();
|
||||
|
||||
foreach ($users as $user) {
|
||||
// set email
|
||||
if (!$user->email) {
|
||||
$user->email = str($user->public_key)->substr(-6).'@portal.einundzwanzig.space';
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire\BookCase;
|
||||
|
||||
use App\Models\BookCase;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class Footer extends Component
|
||||
$toTranslate = Translation::query()
|
||||
->where('language_id', $language->id)
|
||||
->count();
|
||||
$toTranslate = $toTranslate > 0 ? $toTranslate : 1;
|
||||
|
||||
return view('livewire.frontend.footer', [
|
||||
'percentTranslated' => $l === 'en' ? 100 : round(($translated / $toTranslate) * 100),
|
||||
|
||||
@@ -7,11 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Spatie\Comments\Exceptions\CannotCreateComment;
|
||||
use Spatie\Comments\Models\Comment;
|
||||
use Spatie\Comments\Models\Concerns\HasComments;
|
||||
use Spatie\Comments\Models\Concerns\Interfaces\CanComment;
|
||||
use Spatie\Comments\Support\Config;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@@ -95,36 +91,4 @@ class BookCase extends Model implements HasMedia
|
||||
{
|
||||
return url()->route('bookCases.comment.bookcase', ['bookCase' => $this->id]);
|
||||
}
|
||||
|
||||
public function comment(string $text, CanComment $commentator = null): Comment
|
||||
{
|
||||
// $commentator ??= auth()->user();
|
||||
|
||||
if (! config('comments.allow_anonymous_comments')) {
|
||||
if (! $commentator) {
|
||||
throw CannotCreateComment::userIsRequired();
|
||||
}
|
||||
}
|
||||
|
||||
$parentId = ($this::class === Config::getCommentModelName())
|
||||
? $this->getKey()
|
||||
: null;
|
||||
|
||||
$comment = $this->comments()->create([
|
||||
'commentator_id' => $commentator?->getKey() ?? null,
|
||||
'commentator_type' => $commentator?->getMorphClass() ?? null,
|
||||
'original_text' => $text,
|
||||
'parent_id' => $parentId,
|
||||
]);
|
||||
|
||||
if ($comment->shouldBeAutomaticallyApproved()) {
|
||||
Config::approveCommentAction()->execute($comment);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
Config::sendNotificationsForPendingCommentAction()->execute($comment);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user