add webln test page

This commit is contained in:
fsociety
2024-09-10 20:29:50 +02:00
parent 0260a61e7e
commit 2077cc9941
509 changed files with 5167 additions and 2240 deletions

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Http\Livewire\Test;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
class WebLN extends Component
{
public function logThis($text)
{
Log::info('WEBLN: ' . $text);
}
public function render()
{
return view('livewire.test.web-l-n')->layout('layouts.test');
}
}

View File

@@ -7,7 +7,6 @@ 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\Models\Concerns\HasComments;
use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
@@ -16,7 +15,6 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
class BookCase extends Model implements HasMedia
{
use HasFactory;
use HasComments;
use InteractsWithMedia;
use Geoly;
@@ -82,22 +80,4 @@ class BookCase extends Model implements HasMedia
{
return $this->hasMany(OrangePill::class);
}
/*
* This string will be used in notifications on what a new comment
* was made.
*/
public function commentableName(): string
{
return __('Bookcase');
}
/*
* This URL will be used in notifications to let the user know
* where the comment itself can be read.
*/
public function commentUrl(): string
{
return url()->route('bookCases.comment.bookcase', ['bookCase' => $this->id]);
}
}

View File

@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Facades\Cookie;
use Spatie\Comments\Models\Concerns\HasComments;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use Spatie\Feed\Feedable;
@@ -27,7 +26,6 @@ class LibraryItem extends Model implements HasMedia, Sortable, Feedable
use SortableTrait;
use HasStatuses;
use HasSlug;
use HasComments;
/**
* The attributes that aren't mass assignable.
@@ -130,25 +128,6 @@ class LibraryItem extends Model implements HasMedia, Sortable, Feedable
return $this->belongsToMany(Library::class);
}
/*
* This URL will be used in notifications to let the user know
* where the comment itself can be read.
*/
public function commentableName(): string
{
return __('Library Item');
}
public function commentUrl(): string
{
if ($this->type === 'markdown_article') {
return url()->route('article.view', ['libraryItem' => $this]);
} else {
return url()->route('libraryItem.view', ['libraryItem' => $this]);
}
}
public function toFeedItem(): CustomFeedItem
{
return CustomFeedItem::create()

View File

@@ -5,12 +5,10 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Comments\Models\Concerns\HasComments;
class MeetupEvent extends Model
{
use HasFactory;
use HasComments;
/**
* The attributes that aren't mass assignable.
@@ -35,7 +33,7 @@ class MeetupEvent extends Model
protected static function booted()
{
static::creating(function ($model) {
if (! $model->created_by) {
if (!$model->created_by) {
$model->created_by = auth()->id();
}
});
@@ -50,22 +48,4 @@ class MeetupEvent extends Model
{
return $this->belongsTo(Meetup::class);
}
/*
* This string will be used in notifications on what a new comment
* was made.
*/
public function commentableName(): string
{
return __('Meetup Event');
}
/*
* This URL will be used in notifications to let the user know
* where the comment itself can be read.
*/
public function commentUrl(): string
{
return url()->route('meetup.event.landing', ['country' => $this->meetup->city->country, 'meetupEvent' => $this]);
}
}

View File

@@ -14,13 +14,11 @@ use ParagonIE\CipherSweet\BlindIndex;
use ParagonIE\CipherSweet\EncryptedRow;
use ParagonIE\CipherSweet\JsonFieldMap;
use QCod\Gamify\Gamify;
use Spatie\Comments\Models\Concerns\InteractsWithComments;
use Spatie\Comments\Models\Concerns\Interfaces\CanComment;
use Spatie\LaravelCipherSweet\Concerns\UsesCipherSweet;
use Spatie\LaravelCipherSweet\Contracts\CipherSweetEncrypted;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements MustVerifyEmail, CanComment, CipherSweetEncrypted
class User extends Authenticatable implements MustVerifyEmail, CipherSweetEncrypted
{
use UsesCipherSweet;
use HasApiTokens;
@@ -30,7 +28,6 @@ class User extends Authenticatable implements MustVerifyEmail, CanComment, Ciphe
use Notifiable;
use TwoFactorAuthenticatable;
use HasRoles;
use InteractsWithComments;
use Gamify;
protected $guarded = [];

View File

@@ -128,8 +128,6 @@ class BookCase extends Resource
HasMany::make(__('OrangePills'), 'orangePills', OrangePill::class),
MorphMany::make(__('Comments'), 'comments', Comment::class),
BelongsTo::make(__('Created By'), 'createdBy', User::class)
->canSee(function ($request) {
return $request->user()

View File

@@ -1,83 +0,0 @@
<?php
namespace App\Nova;
use App\Notifications\ModelCreatedNotification;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\MorphTo;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Spatie\Comments\Models\Comment as CommentModel;
class Comment extends Resource
{
public static $model = CommentModel::class;
public static $search = [
'id', 'text',
];
public static function authorizedToCreate(Request $request)
{
return auth()
->user()
?->hasRole('super-admin');
}
public function authorizedToUpdate(Request $request)
{
return auth()
->user()
?->hasRole('super-admin');
}
public static function afterCreate(NovaRequest $request, Model $model)
{
\App\Models\User::find(1)
->notify(new ModelCreatedNotification($model, str($request->getRequestUri())
->after('/nova-api/')
->before('?')
->toString()));
}
public function fields(NovaRequest $request)
{
return [
Text::make(__('Title'), function (CommentModel $comment) {
return $comment->topLevel()->commentable?->commentableName() ?? 'Deleted...';
})
->readonly(),
MorphTo::make(__('Commentator'), 'commentator')
->types([
User::class,
]),
Markdown::make(__('Original text'), 'original_text'),
Text::make('', function (CommentModel $comment) {
if (! $url = $comment?->commentUrl()) {
return '';
}
return "<a target=\"show_comment\" href=\"{$url}\">".__('Show').'</a>';
})
->asHtml(),
Text::make(__('Status'), function (CommentModel $comment) {
if ($comment->isApproved()) {
return "<div class='inline-flex items-center px-3 py-0.5 rounded-full text-sm font-medium bg-green-100 text-green-800'>Approved</div>";
}
return "<div class='inline-flex items-center px-3 py-0.5 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800'>Pending</div>";
})
->asHtml(),
DateTime::make(__('Created at'), 'created_at'),
];
}
}

View File

@@ -6,7 +6,6 @@ use App\Nova\BitcoinEvent;
use App\Nova\BookCase;
use App\Nova\Category;
use App\Nova\City;
use App\Nova\Comment;
use App\Nova\Country;
use App\Nova\Course;
use App\Nova\CourseEvent;
@@ -44,15 +43,6 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
parent::boot();
Nova::mainMenu(function (Request $request) {
$comments = $request->user()
->hasRole('super-admin') || $request->user()
->can('CommentPolicy.viewAny') ? [
MenuSection::make('Comments', [
MenuItem::resource(Comment::class),
])
->icon('chat')
->collapsable(),
] : [];
$adminItems = $request->user()
->hasRole('super-admin') || $request->user()
@@ -151,7 +141,7 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
->icon('book-open')
->collapsable(),
], $comments, $adminItems, $permissions);
], $adminItems, $permissions);
});
Nova::withBreadcrumbs();