Skip to content

Commit

Permalink
2024-03-04までの原文変更点反映。
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroKws committed Mar 4, 2024
1 parent 0858c49 commit 9bdaf58
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 59 deletions.
18 changes: 16 additions & 2 deletions original-en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,31 @@ php artisan env:decrypt --force
<a name="accessing-configuration-values"></a>
## Accessing Configuration Values

You may easily access your configuration values using the global `config` function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:
You may easily access your configuration values using the `Config` facade or global `config` function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:

use Illuminate\Support\Facades\Config;

$value = Config::get('app.timezone');

$value = config('app.timezone');

// Retrieve a default value if the configuration value does not exist...
$value = config('app.timezone', 'Asia/Seoul');

To set configuration values at runtime, pass an array to the `config` function:
To set configuration values at runtime, you may invoke the `Config` facade's `set` method or pass an array to the `config` function:

Config::set('app.timezone', 'America/Chicago');

config(['app.timezone' => 'America/Chicago']);

To assist with static analysis, the `Config` facade also provides typed configuration retrieval methods. If the retrieved configuration value does not match the expected type, an exception will be thrown:

Config::string('config-key');
Config::integer('config-key');
Config::float('config-key');
Config::boolean('config-key');
Config::array('config-key');

<a name="configuration-caching"></a>
## Configuration Caching

Expand Down
18 changes: 0 additions & 18 deletions original-en/eloquent-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,24 +334,6 @@ By default, your outermost resource is wrapped in a `data` key when the resource
}
```

If you would like to use a custom key instead of `data`, you may define a `$wrap` attribute on the resource class:

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
/**
* The "data" wrapper that should be applied.
*
* @var string|null
*/
public static $wrap = 'user';
}

If you would like to disable the wrapping of the outermost resource, you should invoke the `withoutWrapping` method on the base `Illuminate\Http\Resources\Json\JsonResource` class. Typically, you should call this method from your `AppServiceProvider` or another [service provider](/docs/{{version}}/providers) that is loaded on every request to your application:

<?php
Expand Down
22 changes: 17 additions & 5 deletions original-en/prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Suggest](#suggest)
- [Search](#search)
- [Multi-search](#multisearch)
- [Pause](#pause)
- [Informational Messages](#informational-messages)
- [Tables](#tables)
- [Spin](#spin)
Expand Down Expand Up @@ -610,8 +611,19 @@ $ids = multisearch(

If the `options` closure returns an associative array, then the closure will receive the selected keys; otherwise, it will receive the selected values. The closure may return an error message, or `null` if the validation passes.

<a name="pause"></a>
### Pause

The `pause` function may be used to display informational text to the user and wait for them to confirm their desire to proceed by pressing the Enter / Return key:

```php
use function Laravel\Prompts\pause;

pause('Press ENTER to continue.');
```

<a name="informational-messages"></a>
### Informational Messages
## Informational Messages

The `note`, `info`, `warning`, `error`, and `alert` functions may be used to display informational messages:

Expand All @@ -622,7 +634,7 @@ info('Package installed successfully.');
```

<a name="tables"></a>
### Tables
## Tables

The `table` function makes it easy to display multiple rows and columns of data. All you need to do is provide the column names and the data for the table:

Expand All @@ -636,7 +648,7 @@ table(
```

<a name="spin"></a>
### Spin
## Spin

The `spin` function displays a spinner along with an optional message while executing a specified callback. It serves to indicate ongoing processes and returns the callback's results upon completion:

Expand Down Expand Up @@ -705,7 +717,7 @@ $progress->finish();
```

<a name="terminal-considerations"></a>
### Terminal Considerations
## Terminal Considerations

<a name="terminal-width"></a>
#### Terminal Width
Expand All @@ -718,7 +730,7 @@ If the length of any label, option, or validation message exceeds the number of
For any prompts that accept the `scroll` argument, the configured value will automatically be reduced to fit the height of the user's terminal, including space for a validation message.

<a name="fallbacks"></a>
### Unsupported Environments and Fallbacks
## Unsupported Environments and Fallbacks

Laravel Prompts supports macOS, Linux, and Windows with WSL. Due to limitations in the Windows version of PHP, it is not currently possible to use Laravel Prompts on Windows outside of WSL.

Expand Down
20 changes: 20 additions & 0 deletions original-en/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,26 @@ You may use the `joinSub`, `leftJoinSub`, and `rightJoinSub` methods to join a q
$join->on('users.id', '=', 'latest_posts.user_id');
})->get();

<a name="lateral-joins"></a>
#### Lateral Joins

> [!WARNING]
> Lateral joins are currently supported by PostgreSQL, MySQL >= 8.0.14, and SQL Server.
You may use the `joinLateral` and `leftJoinLateral` methods to perform a "lateral join" with a subquery. Each of these methods receives two arguments: the subquery and its table alias. The join condition(s) should be specified within the `where` clause of the given subquery. Lateral joins are evaluated for each row and can reference columns outside the subquery.

In this example, we will retrieve a collection of users as well as the user's three most recent blog posts. Each user can produce up to three rows in the result set: one for each of their most recent blog posts. The join condition is specified with a `whereColumn` clause within the subquery, referencing the current user row:

$latestPosts = DB::table('posts')
->select('id as post_id', 'title as post_title', 'created_at as post_created_at')
->whereColumn('user_id', 'users.id')
->orderBy('created_at', 'desc')
->limit(3);

$users = DB::table('users')
->joinLateral($latestPosts, 'latest_posts')
->get();

<a name="unions"></a>
## Unions

Expand Down
12 changes: 8 additions & 4 deletions original-en/rate-limiting.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,24 @@ If you would like to manually interact with the rate limiter, a variety of other
return 'Too many attempts!';
}

RateLimiter::hit('send-message:'.$user->id);
RateLimiter::increment('send-message:'.$user->id);

// Send message...

Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `hit` method to increment the number of total attempts:
Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `increment` method to increment the number of total attempts:

use Illuminate\Support\Facades\RateLimiter;

if (RateLimiter::remaining('send-message:'.$user->id, $perMinute = 5)) {
RateLimiter::hit('send-message:'.$user->id);
RateLimiter::increment('send-message:'.$user->id);

// Send message...
}

If you would like to increment the value for a given rate limiter key by more than one, you may provide the desired amount to the `increment` method:

RateLimiter::increment('send-message:'.$user->id, amount: 5);

<a name="determining-limiter-availability"></a>
#### Determining Limiter Availability

Expand All @@ -93,7 +97,7 @@ When a key has no more attempts left, the `availableIn` method returns the numbe
return 'You may try again in '.$seconds.' seconds.';
}

RateLimiter::hit('send-message:'.$user->id);
RateLimiter::increment('send-message:'.$user->id);

// Send message...

Expand Down
8 changes: 8 additions & 0 deletions original-en/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ The `Str::isUrl` method determines if the given string is a valid URL:

// false

The `isUrl` method considers a wide range of protocols as valid. However, you may specify the protocols that should be considered valid by providing them to the `isUrl` method:

$isUrl = Str::isUrl('http://example.com', ['http', 'https']);

<a name="method-str-is-ulid"></a>
#### `Str::isUlid()` {.collection-method}

Expand Down Expand Up @@ -1758,6 +1762,10 @@ The `isUrl` method determines if a given string is a URL:

// false

The `isUrl` method considers a wide range of protocols as valid. However, you may specify the protocols that should be considered valid by providing them to the `isUrl` method:

$result = Str::of('http://example.com')->isUrl(['http', 'https']);

<a name="method-fluent-str-is-uuid"></a>
#### `isUuid` {.collection-method}

Expand Down
2 changes: 2 additions & 0 deletions original-en/telescope.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ php artisan telescope:install
php artisan migrate
```

Finally, you may access the Telescope dashboard via the `/telescope` route.

<a name="migration-customization"></a>
#### Migration Customization

Expand Down
22 changes: 22 additions & 0 deletions original-en/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,28 @@ The `Enum` rule is a class based rule that validates whether the field under val
'status' => [Rule::enum(ServerStatus::class)],
]);

The `Enum` rule's `only` and `except` methods may be used to limit which enum cases should be considered valid:

Rule::enum(ServerStatus::class)
->only([ServerStatus::Pending, ServerStatus::Active]);

Rule::enum(ServerStatus::class)
->except([ServerStatus::Pending, ServerStatus::Active]);

The `when` method may be used to conditionally modify the `Enum` rule:

```php
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;

Rule::enum(ServerStatus::class)
->when(
Auth::user()->isAdmin(),
fn ($rule) => $rule->only(...),
fn ($rule) => $rule->only(...),
);
```

<a name="rule-exclude"></a>
#### exclude

Expand Down
18 changes: 16 additions & 2 deletions translation-ja/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,31 @@ php artisan env:decrypt --force
<a name="accessing-configuration-values"></a>
## 設定値へのアクセス

アプリケーションのどこからでもグローバルの`config`関数を使用し、設定値へ簡単にアクセスできます。設定値はファイルとオプションの名前を含む「ドット」記法を使いアクセスします。デフォルト値も指定でき、設定オプションが存在しない場合に、返されます。
アプリケーションのどこからでも、`Config`ファサードと`config`グローバル関数を使い、簡単に設定値にアクセスできます。設定値には「ドット」構文を使いアクセスでき、アクセスしたいファイル名とオプション名を指定します。デフォルト値を指定することもでき、その設定オプションが存在しない場合に返します。

use Illuminate\Support\Facades\Config;

$value = Config::get('app.timezone');

$value = config('app.timezone');

// 設定値が存在しない場合、デフォルト値を取得する
$value = config('app.timezone', 'Asia/Seoul');

実行時に設定値をセットするには、`config`関数へ配列で渡してください。
実行時に設定値をセットするには、`Config`ファサードの`set`メソッドを呼び出すか、`config` 関数に配列を渡します。

Config::set('app.timezone', 'America/Chicago');

config(['app.timezone' => 'America/Chicago']);

静的解析を支援するため、`Config`ファサードは型付き設定値取得メソッドも提供しています。取得した設定値が期待している型と一致しない場合は、例外を投げます。

Config::string('config-key');
Config::integer('config-key');
Config::float('config-key');
Config::boolean('config-key');
Config::array('config-key');

<a name="configuration-caching"></a>
## 設定キャッシュ

Expand Down
18 changes: 0 additions & 18 deletions translation-ja/eloquent-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,24 +334,6 @@ php artisan make:resource UserCollection
}
```

`data`の代わりにカスタムキーを使用したい場合は、リソースクラスに`$wrap`属性を定義します。

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
/**
* 適用する「データ」ラッパー
*
* @var string|null
*/
public static $wrap = 'user';
}

最も外側のリソースのラッピングを無効にする場合は、ベースの`Illuminate\Http\Resources\Json\JsonResource`クラスで`withoutWrapping`メソッドを呼び出す必要があります。通常、このメソッドは、アプリケーションへのすべてのリクエストで読み込まれる`AppServiceProvider`か、別の[サービスプロバイダ](/docs/{{version}}/provider)から呼び出す必要があります。

<?php
Expand Down
22 changes: 17 additions & 5 deletions translation-ja/prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [候補](#suggest)
- [検索](#search)
- [マルチ検索](#multisearch)
- [一時停止](#pause)
- [情報メッセージ](#informational-messages)
- [テーブル](#tables)
- [スピン](#spin)
Expand Down Expand Up @@ -610,8 +611,19 @@ $ids = multisearch(

`options`クロージャが連想配列を返す場合、クロージャは選択済みのキーを受け取ります。そうでない場合は、選択済みの値を受け取ります。クロージャはエラーメッセージを返すか、バリデーションに合格した場合は`null`を返します。

<a name="pause"></a>
### 一時停止

`pause`関数は、ユーザーへ情報テキストを表示し、Enter/Returnキーが押されるのを待つことにより、ユーザーの続行の意思を確認するために使用します。

```php
use function Laravel\Prompts\pause;

pause('Press ENTER to continue.');
```

<a name="informational-messages"></a>
### 情報メッセージ
## 情報メッセージ

`note``info``warning``error``alert`関数は、情報メッセージを表示するために使用します。

Expand All @@ -622,7 +634,7 @@ info('Package installed successfully.');
```

<a name="tables"></a>
### テーブル
## テーブル

`table`関数を使うと、複数の行や列のデータを簡単に表示できます。指定する必要があるのは、カラム名とテーブルのデータだけです。

Expand All @@ -636,7 +648,7 @@ table(
```

<a name="spin"></a>
### スピン
## スピン

`spin`関数は、指定したコールバックを実行している間、オプションのメッセージとともにスピナーを表示します。これは進行中の処理を示す役割を果たし、完了するとコールバックの結果を返します。

Expand Down Expand Up @@ -705,7 +717,7 @@ $progress->finish();
```

<a name="terminal-considerations"></a>
### ターミナルの考察
## ターミナルの考察

<a name="terminal-width"></a>
#### ターミナルの横幅
Expand All @@ -718,7 +730,7 @@ $progress->finish();
`scroll`引数を受け入れるプロンプトの場合、設定済み値は、検証メッセージ用のスペースを含めて、ユーザーの端末の高さに合わせて自動的に縮小されます。

<a name="fallbacks"></a>
### 未サポートの環境とフォールバック
## 未サポートの環境とフォールバック

Laravel PromptsはmacOS、Linux、WindowsのWSLをサポートしています。Windows版のPHPの制限により、現在のところWSL以外のWindowsでは、Laravel Promptsを使用できません。

Expand Down
20 changes: 20 additions & 0 deletions translation-ja/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,26 @@ DB::table('users')->where('active', false)
$join->on('users.id', '=', 'latest_posts.user_id');
})->get();

<a name="lateral-joins"></a>
#### ラテラルJoin

> [!WARNING]
> 現在、ラテラルJoinはPostgreSQL、MySQL8.0.14以上、SQL Serverでサポートされています。
`joinLateral` メソッドと `leftJoinLateral` メソッドを使用すると、サブクエリとの「ラテラル結合」を行えます。これらのメソッドはそれぞれ2つの引数を取ります。サブクエリとそのテーブルエイリアスです。結合条件は、指定するサブクエリの中で、`where`節で指定する必要があります。ラテラル結合は行ごとに評価され、サブクエリ外の列を参照できます。

この例では、ユーザーのコレクションと同時に、各ユーザーの最新ブログ記事を3つ取得しています。各ユーザーは結果セットへ最大3つの行を生成できます: 最新ブログ投稿それぞれに対して1つずつです。結合条件は、サブクエリ内の`whereColumn`節で指定し、現在のユーザー行を参照しています。

$latestPosts = DB::table('posts')
->select('id as post_id', 'title as post_title', 'created_at as post_created_at')
->whereColumn('user_id', 'users.id')
->orderBy('created_at', 'desc')
->limit(3);

$users = DB::table('users')
->joinLateral($latestPosts, 'latest_posts')
->get();

<a name="unions"></a>
## UNION

Expand Down
Loading

0 comments on commit 9bdaf58

Please sign in to comment.