Skip to content

Commit

Permalink
2024-02-20までの原文変更点反映。
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroKws committed Feb 20, 2024
1 parent bf22d84 commit 1396417
Show file tree
Hide file tree
Showing 20 changed files with 318 additions and 70 deletions.
12 changes: 11 additions & 1 deletion original-en/billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,17 @@ Next, let's build the Checkout success route. This is the route that users will
Route::get('/checkout/success', function (Request $request) {
$sessionId = $request->get('session_id');

$orderId = Cashier::stripe()->checkout->sessions->retrieve($sessionId)['metadata']['order_id'] ?? null;
if ($sessionId === null) {
return;
}

$session = Cashier::stripe()->checkout->sessions->retrieve($sessionId);

if ($session->payment_status !== 'paid') {
return;
}

$orderId = $session['metadata']['order_id'] ?? null;

$order = Order::findOrFail($orderId);

Expand Down
8 changes: 8 additions & 0 deletions original-en/blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,14 @@ You may invoke a slot's `isEmpty` method to determine if the slot contains conte
</div>
```

Additionally, the `hasActualContent` method may be used to determine if the slot contains any "actual" content that is not an HTML comment:

```blade
@if ($slot->hasActualContent())
The scope has non-comment content.
@endif
```

<a name="scoped-slots"></a>
#### Scoped Slots

Expand Down
2 changes: 1 addition & 1 deletion original-en/cashier-paddle.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ If you have billable entities that are not users, you may also add the trait to
Next, you should configure your Paddle keys in your application's `.env` file. You can retrieve your Paddle API keys from the Paddle control panel:

```ini
PADDLE_SELLER_ID=your-paddle-seller-id
PADDLE_CLIENT_SIDE_TOKEN=your-paddle-client-side-token
PADDLE_API_KEY=your-paddle-api-key
PADDLE_RETAIN_KEY=your-paddle-retain-key
PADDLE_WEBHOOK_SECRET="your-paddle-webhook-secret"
Expand Down
22 changes: 22 additions & 0 deletions original-en/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ For the majority of the remaining collection documentation, we'll discuss each m
[replaceRecursive](#method-replacerecursive)
[reverse](#method-reverse)
[search](#method-search)
[select](#method-select)
[shift](#method-shift)
[shuffle](#method-shuffle)
[skip](#method-skip)
Expand Down Expand Up @@ -2142,6 +2143,27 @@ Alternatively, you may provide your own closure to search for the first item tha

// 2

<a name="method-select"></a>
#### `select()` {.collection-method}

The `select` method selects the given keys from the collection, similar to an SQL `SELECT` statement:

```php
$users = collect([
['name' => 'Taylor Otwell', 'role' => 'Developer', 'status' => 'active'],
['name' => 'Victoria Faith', 'role' => 'Researcher', 'status' => 'active'],
]);

$users->select(['name', 'role']);

/*
[
['name' => 'Taylor Otwell', 'role' => 'Developer'],
['name' => 'Victoria Faith', 'role' => 'Researcher'],
],
*/
```

<a name="method-shift"></a>
#### `shift()` {.collection-method}

Expand Down
42 changes: 27 additions & 15 deletions original-en/eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,22 @@ Writing a global scope is simple. First, use the `make:scope` command to generat
<a name="applying-global-scopes"></a>
#### Applying Global Scopes

To assign a global scope to a model, you should override the model's `booted` method and invoke the model's `addGlobalScope` method. The `addGlobalScope` method accepts an instance of your scope as its only argument:
To assign a global scope to a model, you may simply place the `ScopedBy` attribute on the model:

<?php

namespace App\Models;

use App\Models\Scopes\AncientScope;
use Illuminate\Database\Eloquent\Attributes\ScopedBy;

#[ScopedBy([AncientScope::class])]
class User extends Model
{
//
}

Or, you may manually register the global scope by overriding the model's `booted` method and invoke the model's `addGlobalScope` method. The `addGlobalScope` method accepts an instance of your scope as its only argument:

<?php

Expand Down Expand Up @@ -1516,32 +1531,29 @@ This command will place the new observer in your `app/Observers` directory. If t
}
}

To register an observer, you need to call the `observe` method on the model you wish to observe. You may register observers in the `boot` method of your application's `App\Providers\EventServiceProvider` service provider:
To register an observer, you may place the `ObservedBy` attribute on the corresponding model:

use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;

/**
* Register any events for your application.
*/
public function boot(): void
#[ObservedBy([UserObserver::class])]
class User extends Authenticatable
{
User::observe(UserObserver::class);
//
}

Alternatively, you may list your observers within an `$observers` property of your applications' `App\Providers\EventServiceProvider` class:
Or, you may manually register an observer by calling the `observe` method on the model you wish to observe. You may register observers in the `boot` method of your application's `App\Providers\EventServiceProvider` service provider:

use App\Models\User;
use App\Observers\UserObserver;

/**
* The model observers for your application.
*
* @var array
* Register any events for your application.
*/
protected $observers = [
User::class => [UserObserver::class],
];
public function boot(): void
{
User::observe(UserObserver::class);
}

> [!NOTE]
> There are additional events an observer can listen to, such as `saving` and `retrieved`. These events are described within the [events](#events) documentation.
Expand Down
32 changes: 28 additions & 4 deletions original-en/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[Arr::sortDesc](#method-array-sort-desc)
[Arr::sortRecursive](#method-array-sort-recursive)
[Arr::sortRecursiveDesc](#method-array-sort-recursive-desc)
[Arr::take](#method-array-take)
[Arr::toCssClasses](#method-array-to-css-classes)
[Arr::toCssStyles](#method-array-to-css-styles)
[Arr::undot](#method-array-undot)
Expand Down Expand Up @@ -842,10 +843,31 @@ If you would like the results sorted in descending order, you may use the `Arr::

$sorted = Arr::sortRecursiveDesc($array);

<a name="method-array-take"></a>
#### `Arr::take()` {.collection-method}

The `Arr::take` method returns a new array with the specified number of items:

use Illuminate\Support\Arr;

$array = [0, 1, 2, 3, 4, 5];

$chunk = Arr::take($array, 3);

// [0, 1, 2]

You may also pass a negative integer to take the specified number of items from the end of the array:

$array = [0, 1, 2, 3, 4, 5];

$chunk = Arr::take($array, -2);

// [4, 5]

<a name="method-array-to-css-classes"></a>
#### `Arr::toCssClasses()` {.collection-method}

The `Arr::toCssClasses` conditionally compiles a CSS class string. The method accepts an array of classes where the array key contains the class or classes you wish to add, while the value is a boolean expression. If the array element has a numeric key, it will always be included in the rendered class list:
The `Arr::toCssClasses` method conditionally compiles a CSS class string. The method accepts an array of classes where the array key contains the class or classes you wish to add, while the value is a boolean expression. If the array element has a numeric key, it will always be included in the rendered class list:

use Illuminate\Support\Arr;

Expand All @@ -866,6 +888,8 @@ The `Arr::toCssClasses` conditionally compiles a CSS class string. The method ac
The `Arr::toCssStyles` conditionally compiles a CSS style string. The method accepts an array of classes where the array key contains the class or classes you wish to add, while the value is a boolean expression. If the array element has a numeric key, it will always be included in the rendered class list:

```php
use Illuminate\Support\Arr;

$hasColor = true;

$array = ['background-color: blue', 'color: blue' => $hasColor];
Expand Down Expand Up @@ -1353,7 +1377,7 @@ The `lang_path` function returns the fully qualified path to your application's

$path = lang_path('en/messages.php');

> [!NOTE]
> [!NOTE]
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
<a name="method-mix"></a>
Expand Down Expand Up @@ -1699,7 +1723,7 @@ The `env` function retrieves the value of an [environment variable](/docs/{{vers

$env = env('APP_ENV', 'production');

> [!WARNING]
> [!WARNING]
> If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return `null`.
<a name="method-event"></a>
Expand Down Expand Up @@ -2087,7 +2111,7 @@ Additional arguments may be passed to the `value` function. If the first argumen
$result = value(function (string $name) {
return $name;
}, 'Taylor');

// 'Taylor'

<a name="method-view"></a>
Expand Down
12 changes: 12 additions & 0 deletions original-en/http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ If you would like the HTTP client to automatically retry the request if a client

$response = Http::retry(3, 100)->post(/* ... */);

If you would like to manually calculate the number of milliseconds to sleep between attempts, you may pass a closure as the second argument to the `retry` method:

use Exception;

$response = Http::retry(3, function (int $attempt, Exception $exception) {
return $attempt * 100;
})->post(/* ... */);

For convenience, you may also provide an array as the first argument to the `retry` method. This array will be used to determine how many milliseconds to sleep between subsequent attempts:

$response = Http::retry([100, 200])->post(/* ... */);

If needed, you may pass a third argument to the `retry` method. The third argument should be a callable that determines if the retries should actually be attempted. For example, you may wish to only retry the request if the initial request encounters an `ConnectionException`:

use Exception;
Expand Down
12 changes: 12 additions & 0 deletions original-en/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ Package translation lines are referenced using the `package::file.line` syntax c

echo trans('courier::messages.welcome');

You can register JSON translation files for your package using the `loadJsonTranslationsFrom` method. This method accepts the path to the directory that contains your package's JSON translation files:

```php
/**
* Bootstrap any package services.
*/
public function boot(): void
{
$this->loadJsonTranslationsFrom(__DIR__.'/../lang');
}
```

<a name="publishing-language-files"></a>
#### Publishing Language Files

Expand Down
2 changes: 1 addition & 1 deletion original-en/sail.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ By default, Sail commands are invoked using the `vendor/bin/sail` script that is
However, instead of repeatedly typing `vendor/bin/sail` to execute Sail commands, you may wish to configure a shell alias that allows you to execute Sail's commands more easily:

```shell
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'
```

To make sure this is always available, you may add this to your shell configuration file in your home directory, such as `~/.zshrc` or `~/.bashrc`, and then restart your shell.
Expand Down
24 changes: 24 additions & 0 deletions original-en/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
[Str::swap](#method-str-swap)
[Str::take](#method-take)
[Str::title](#method-title-case)
[Str::toBase64](#method-str-to-base64)
[Str::toHtmlString](#method-str-to-html-string)
[Str::ucfirst](#method-str-ucfirst)
[Str::ucsplit](#method-str-ucsplit)
Expand Down Expand Up @@ -194,6 +195,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
[tap](#method-fluent-str-tap)
[test](#method-fluent-str-test)
[title](#method-fluent-str-title)
[toBase64](#method-fluent-str-to-base64)
[trim](#method-fluent-str-trim)
[ucfirst](#method-fluent-str-ucfirst)
[ucsplit](#method-fluent-str-ucsplit)
Expand Down Expand Up @@ -1145,6 +1147,17 @@ The `Str::title` method converts the given string to `Title Case`:

// A Nice Title Uses The Correct Case

<a name="method-str-to-base64"></a>
#### `Str::toBase64()` {.collection-method}

The `Str::toBase64` method converts the given string to Base64:

use Illuminate\Support\Str;

$base64 = Str::toBase64('Laravel');

// TGFyYXZlbA==

<a name="method-str-to-html-string"></a>
#### `Str::toHtmlString()` {.collection-method}

Expand Down Expand Up @@ -2417,6 +2430,17 @@ The `title` method converts the given string to `Title Case`:

// A Nice Title Uses The Correct Case

<a name="method-fluent-str-to-base64"></a>
#### `toBase64()` {.collection-method}

The `toBase64` method converts the given string to Base64:

use Illuminate\Support\Str;

$base64 = Str::of('Laravel')->toBase64();

// TGFyYXZlbA==

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

Expand Down
12 changes: 11 additions & 1 deletion translation-ja/billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,17 @@ StripeへのAPI呼び出しで発生した例外は、アプリケーション
Route::get('/checkout/success', function (Request $request) {
$sessionId = $request->get('session_id');

$orderId = Cashier::stripe()->checkout->sessions->retrieve($sessionId)['metadata']['order_id'] ?? null;
if ($sessionId === null) {
return;
}

$session = Cashier::stripe()->checkout->sessions->retrieve($sessionId);

if ($session->payment_status !== 'paid') {
return;
}

$orderId = $session['metadata']['order_id'] ?? null;

$order = Order::findOrFail($orderId);

Expand Down
16 changes: 12 additions & 4 deletions translation-ja/blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ public function __construct(

```blade
<x-alert>
<strong>Whoops!</strong> Something went wrong!
<strong>おっと!</strong> なにかおかしいようです!
</x-alert>
```

Expand All @@ -1150,7 +1150,7 @@ public function __construct(
Server Error
</x-slot>

<strong>Whoops!</strong> Something went wrong!
<strong>おっと!</strong> なにかおかしいようです!
</x-alert>
```

Expand All @@ -1161,13 +1161,21 @@ public function __construct(
<div class="alert alert-danger">
@if ($slot->isEmpty())
This is default content if the slot is empty.
ここはスロットが空の場合のデフォルトコンテンツ.
@else
{{ $slot }}
@endif
</div>
```

さらに、`hasActualContent`メソッドを使用して、スロットにHTMLコメントではない「本当」のコンテンツが含まれているかを判定できます。

```blade
@if ($slot->hasActualContent())
コメントではないコンテンツを持つスコープ。
@endif
```

<a name="scoped-slots"></a>
#### スコープ付きスロット

Expand All @@ -1179,7 +1187,7 @@ VueのようなJavaScriptフレームワークを使用している方は「ス
{{ $component->formatAlert('Server Error') }}
</x-slot>
<strong>Whoops!</strong> Something went wrong!
<strong>おっと!</strong> なにかおかしいようです!
</x-alert>
```

Expand Down
Loading

0 comments on commit 1396417

Please sign in to comment.