mirror of
https://github.com/flarum/framework.git
synced 2025-03-02 06:29:56 +08:00
chore: review
This commit is contained in:
parent
80ded88692
commit
7ea25d33d9
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
use Flarum\Api\Resource;
|
||||
use Flarum\Api\Schema;
|
||||
use Flarum\Approval\Access;
|
||||
use Flarum\Approval\Api\DiscussionResourceFields;
|
||||
use Flarum\Approval\Api\PostResourceFields;
|
||||
@ -38,7 +39,9 @@ return [
|
||||
->cast('is_approved', 'bool'),
|
||||
|
||||
(new Extend\ApiResource(Resource\DiscussionResource::class))
|
||||
->fields(DiscussionResourceFields::class),
|
||||
->fields(fn () => [
|
||||
Schema\Boolean::make('isApproved'),
|
||||
]),
|
||||
|
||||
(new Extend\ApiResource(Resource\PostResource::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\Schema;
|
||||
use Flarum\Flags\Flag;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
|
||||
class ForumResourceFields
|
||||
{
|
||||
public function __construct(
|
||||
protected SettingsRepositoryInterface $settings
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(): array
|
||||
{
|
||||
return [
|
||||
|
@ -19,7 +19,7 @@ class UserResourceFields
|
||||
{
|
||||
return [
|
||||
Schema\Str::make('subscription')
|
||||
->writable(fn (Discussion $discussion, Context $context) => $context->updating() && ! $context->getActor()->isGuest())
|
||||
->writable(fn (Discussion $discussion, Context $context) => $context->updating())
|
||||
->nullable()
|
||||
->get(fn (Discussion $discussion) => $discussion->state?->subscription)
|
||||
->set(function (Discussion $discussion, ?string $subscription, Context $context) {
|
||||
|
@ -121,7 +121,7 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
||||
include,
|
||||
};
|
||||
|
||||
if (!params.include) {
|
||||
if (typeof params.include === 'undefined') {
|
||||
delete params.include;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ validation:
|
||||
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."
|
||||
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."
|
||||
numeric: "The :attribute field must be between :min and :max."
|
||||
string: "The :attribute field must be between :min and :max characters."
|
||||
|
Loading…
x
Reference in New Issue
Block a user