mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
chore: review
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Flarum\Api\Resource;
|
use Flarum\Api\Resource;
|
||||||
|
use Flarum\Api\Schema;
|
||||||
use Flarum\Approval\Access;
|
use Flarum\Approval\Access;
|
||||||
use Flarum\Approval\Api\DiscussionResourceFields;
|
use Flarum\Approval\Api\DiscussionResourceFields;
|
||||||
use Flarum\Approval\Api\PostResourceFields;
|
use Flarum\Approval\Api\PostResourceFields;
|
||||||
@@ -38,7 +39,9 @@ return [
|
|||||||
->cast('is_approved', 'bool'),
|
->cast('is_approved', 'bool'),
|
||||||
|
|
||||||
(new Extend\ApiResource(Resource\DiscussionResource::class))
|
(new Extend\ApiResource(Resource\DiscussionResource::class))
|
||||||
->fields(DiscussionResourceFields::class),
|
->fields(fn () => [
|
||||||
|
Schema\Boolean::make('isApproved'),
|
||||||
|
]),
|
||||||
|
|
||||||
(new Extend\ApiResource(Resource\PostResource::class))
|
(new Extend\ApiResource(Resource\PostResource::class))
|
||||||
->fields(PostResourceFields::class),
|
->fields(PostResourceFields::class),
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* For detailed copyright and license information, please view the
|
|
||||||
* LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Approval\Api;
|
|
||||||
|
|
||||||
use Flarum\Api\Schema;
|
|
||||||
|
|
||||||
class DiscussionResourceFields
|
|
||||||
{
|
|
||||||
public function __invoke(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Schema\Boolean::make('isApproved'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@@ -12,15 +12,9 @@ namespace Flarum\Flags\Api;
|
|||||||
use Flarum\Api\Context;
|
use Flarum\Api\Context;
|
||||||
use Flarum\Api\Schema;
|
use Flarum\Api\Schema;
|
||||||
use Flarum\Flags\Flag;
|
use Flarum\Flags\Flag;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
|
||||||
|
|
||||||
class ForumResourceFields
|
class ForumResourceFields
|
||||||
{
|
{
|
||||||
public function __construct(
|
|
||||||
protected SettingsRepositoryInterface $settings
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __invoke(): array
|
public function __invoke(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@@ -19,7 +19,7 @@ class UserResourceFields
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Schema\Str::make('subscription')
|
Schema\Str::make('subscription')
|
||||||
->writable(fn (Discussion $discussion, Context $context) => $context->updating() && ! $context->getActor()->isGuest())
|
->writable(fn (Discussion $discussion, Context $context) => $context->updating())
|
||||||
->nullable()
|
->nullable()
|
||||||
->get(fn (Discussion $discussion) => $discussion->state?->subscription)
|
->get(fn (Discussion $discussion) => $discussion->state?->subscription)
|
||||||
->set(function (Discussion $discussion, ?string $subscription, Context $context) {
|
->set(function (Discussion $discussion, ?string $subscription, Context $context) {
|
||||||
|
@@ -121,7 +121,7 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
|||||||
include,
|
include,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!params.include) {
|
if (typeof params.include === 'undefined') {
|
||||||
delete params.include;
|
delete params.include;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ validation:
|
|||||||
before: "The :attribute field must be a date before :date."
|
before: "The :attribute field must be a date before :date."
|
||||||
before_or_equal: "The :attribute field must be a date before or equal to :date."
|
before_or_equal: "The :attribute field must be a date before or equal to :date."
|
||||||
between:
|
between:
|
||||||
array: "The :attribute field must have between :min and :max items."
|
array: "The :attribute field must contain between :min and :max items."
|
||||||
file: "The :attribute field must be between :min and :max kilobytes."
|
file: "The :attribute field must be between :min and :max kilobytes."
|
||||||
numeric: "The :attribute field must be between :min and :max."
|
numeric: "The :attribute field must be between :min and :max."
|
||||||
string: "The :attribute field must be between :min and :max characters."
|
string: "The :attribute field must be between :min and :max characters."
|
||||||
|
Reference in New Issue
Block a user