livewire/livewire v3.3.5
https://github.com/livewire/livewire/releases/tag/v3.3.5
リリースノートの要約(日本語):
- Laravel 11への対応が追加されました。(@nunomaduroによる貢献)
- PHPUnitの属性に関する変更が元に戻されました。(@nunomaduroによる貢献)
- 複数のデータベース接続を持つレガシーモデルの問題が修正されました。(@jasonlbeggsによる貢献)
完全な変更履歴は、GitHubの比較ページ(v3.3.4からv3.3.5への変更)で確認できます。
#laravel
livewire/livewire v3.3.4
https://github.com/livewire/livewire/releases/tag/v3.3.4
リリースノートの要約(日本語):
変更点:
- @calebporzioが、遅延コンポーネントのページネーションクエリ文字列の問題を修正しました。
- @calebporzioが、コンポーネントの隔離機能(#[Isolate] 属性)を追加しました。
- @lrljoeが、Livewireのバージョン3では`livewire:discover`が冗長であることをアップグレードガイドに注記しました。
新しい貢献者:
- @Bird87ZAが初めて貢献しました。
- @browner12が初めて貢献しました。
完全な変更履歴:https://github.com/livewire/livewire/compare/v3.3.3...v3.3.4
#laravel
Use the Eloquent `with()` method to eager load relationships and avoid the N+1 query problem.
When you're dealing with related models in Laravel, eager loading is a technique to load all related model data in a single query. This helps to avoid the issue where you would otherwise execute one additional query for every single item in a collection to retrieve its related models (known as the N+1 query problem).
For example, if you have a `Post` model that has many `Comments`, instead of doing this:
```php
$posts = Post::all();
foreach ($posts as $post) {
echo $post->comments; // This causes an additional query for each post
}
```
Do this:
```php
$posts = Post::with('comments')->get();
foreach ($posts as $post) {
echo $post->comments; // Comments are already loaded and no extra queries are made
}
```
This simple change can significantly improve the performance of your application when dealing with large datasets.
#laravel
laravel/jetstream v4.2.1
https://github.com/laravel/jetstream/releases/tag/v4.2.1
- PHPUnitテストスタブ内の到達不可能な`return`文を削除しました。この変更は@nathanheffleyによって提案され、https://github.com/laravel/jetstream/pull/1423 で実施されました。
- `UpdateUserProfileInformation::update`メソッドのPHPDocを修正しました。この修正は@rstefanicによって行われ、https://github.com/laravel/jetstream/pull/1424 で行われました。
#laravel
laravel/laravel v10.3.1
https://github.com/laravel/laravel/releases/tag/v10.3.1
Laravelのバージョン10.xにおいて、@me-shaonによってGitHubのプルリクエスト https://github.com/laravel/laravel/pull/6301 で追加された新機能の要約は以下の通りです。
- ラウンドロビン方式のトランスポートドライバー設定が追加されました。
これにより、Laravelのメール送信機能で使用するトランスポートドライバーにラウンドロビン方式を適用することができるようになります。これは、複数のメールサーバーを均等に利用してメールを送信する際に役立ちます。
#laravel
laravel/framework v10.39.0
https://github.com/laravel/framework/releases/tag/v10.39.0
- Laravel 9.xでは、@MichalHubatkaによってphpredis 6.0.0がサポートされるようになりました。
- Laravel 10.xでは、キューに入れられたジョブの`maxTries`を動的に設定できるように@mechelonが改善しました。
- Laravel 10.xでは、PHPが8.3未満の場合にjson検証ルールを使用したときにTypeErrorが発生しないように@Xint0が修正しました。
- Laravel 10.xでは、Bladeテンプレート内のuse文のコンパイルに関する問題を@MrPunyapalが修正しました。
- Laravel 10.xでは、プロンプトの検証をテストできるように@cerbero90が機能を追加しました。
- Laravel 10.xでは、Symfonyメーラーのトランスポートドライバーとして'Roundrobin'を追加するための@me-shaonのプルリクエストがあります。
#laravel
了解しました。Laravelの公式ドキュメントから「データベース:クエリビルダ」のページを選択し、日本語で説明いたします。
Laravelでは、「クエリビルダ」とは、データベースからデータを取得したり、挿入、更新、削除するための流暢なインターフェースを提供する強力なツールです。クエリビルダはPDOパラメータバインディングを使用しており、SQLインジェクション攻撃を阻止するのに役立ちます。
クエリビルダは、データベースファサードの`DB`クラスを使用して利用できます。例えば、データを取得する簡単なSELECTクエリは以下のように記述されます。
```php
$users = DB::table('users')->get();
```
このコードは`users`テーブルから全てのデータ列を取得します。
また、特定の列のみを取得するためには、`select`メソッドを使用します。
```php
$users = DB::table('users')->select('name', 'email as user_email')->get();
```
ここでは、`name`と`email`列だけを指定しており、`email`列は`user_email`として取得します。
条件付きでデータを取得する場合は、`where`メソッドを利用します。
```php
$users = DB::table('users')->where('votes', '>', 100)->get();
```
この例では、`votes`が100より大きいレコードのみを取得しています。
クエリビルダは、ジョイン、ユニオン、グループ化などのより複雑なクエリ操作もサポートしています。さらに、クエリを実行する前に`toSql`メソッドを使ってSQLクエリ文字列をプレビューすることも可能です。
挿入操作はまた簡単で、以下のように行います。
```php
DB::table('users')->insert(
['email' => 'example@example.com', 'votes' => 0]
);
```
このコードは新しいユーザーを`users`テーブルに追加します。
更新と削除も同様に直感的で、以下のように行えます。
```php
DB::table('users')->where('id', 1)->update(['votes' => 1]);
```
```php
DB::table('users')->where('votes', '<', 50)->delete();
```
上記は、それぞれidが1のユーザーのvotesを更新したり、votesが50より小さいユーザーを削除する例です。
クエリビルダは、LaravelのEloquent ORMと一緒にまたは、独自に使われることが多く、効率的で読みやすいデータベース操作を実現するための強力なツールです。
#laravel
laravel/framework v10.38.2
https://github.com/laravel/framework/releases/tag/v10.38.2
- `illuminate/database`に`doctrine/dbal:^4.0`との競合を追加しました。これは@crynoboneによるプルリクエストで、Laravelフレームワークのバージョン10.xに関するものです。
- `Arr::dot`関数を簡素化しました。この変更は@bastien-phiが行いました。
- `Illuminate\Filesystem\join_paths()`関数で、第2引数にnullが与えられた場合の問題を修正しました。この修正は@tylernathanreedによるものです。
- テスト中に非推奨のログを許可する機能を追加しました。これは@timacdonaldが行った変更です。
- ネストされた配列で動作しなかったバリデーションルールの不足を修正しました。この修正は@aabadawyによって行われました。
#laravel
laravel/framework v10.38.1
https://github.com/laravel/framework/releases/tag/v10.38.1
- Laravel 10.xでは、匿名クラスからのパースコールバックをサポートする機能が@nunomaduroによって追加されました。
- @taylorotwellによる「新しいプライマリーキーを追加する際に既存のプライマリーキーを削除する」という変更が取り消されました。
- @timacdonaldにより、新規アプリケーションにDBALをインストールする際の問題が修正されました。
- @dododedodonlによって、リクエストを作成する新しいメソッドが追加されました。
- `Illuminate\Foundation\Application::joinPaths()`メソッドが@crynoboneによって`Illuminate\Filesystem\join_paths()`に移動されました。
#laravel
#### Question:
How do I manage database migrations in Laravel?
#### Answer:
Laravel's migration system provides a way to programmatically define and modify your application's database schema. To manage database migrations, you should use the `artisan` command-line tool that comes with Laravel. Here's an overview of the steps and commands involved:
1. **Creating Migrations:**
To create a new migration, run `php artisan make:migration create_your_table_name_table`. This will create a new migration file in the `database/migrations` directory. You can then add your table definition or changes within the `up()` method for creating/updating tables or indices, and use the `down()` method to define how to revert the operations (usually a drop or delete operation).
2. **Running Migrations:**
To apply your migrations to the database, run the command `php artisan migrate`. This will execute the `up()` method in your migration classes in the order they were created.
3. **Rolling Back Migrations:**
If you need to revert the last batch of migrations, you can run `php artisan migrate:rollback`. This will call the `down()` method on each migration from the last batch. If you want to roll back all migrations, you can use `php artisan migrate:reset`.
4. **Refreshing and Resetting:**
If you want to rebuild your entire database, you can use `php artisan migrate:refresh`, which rolls back all of your migrations and then applies them again. This is useful during development when you need to reinitialize the database schema. There's also `php artisan migrate:refresh --seed`, which will also run your seeders after refreshing the migrations.
5. **Seeding:**
Database seeding allows you to populate your database with test or initial data. You can create seeders using `php artisan make:seeder YourSeeder` and then define the data within the `run()` method of your seeder class. After creating seeders, you can run them with `php artisan db:seed`.
Always ensure you're managing migrations and seeds appropriately across your development, staging, and production environments, as running migrations improperly can lead to data loss or database corruption.
Remember to add new migrations for any changes to the schema instead of editing existing migrations once they have been run on a production environment. This is because editing migrations that are already in use can cause inconsistencies and data issues. Keep your migrations atomic and clear, and always back up your database before running migrations on a live system.
#laravel
livewire/livewire v3.3.3
https://github.com/livewire/livewire/releases/tag/v3.3.3
このリリースノートの要約は以下の通りです。
変更点:
- ドキュメント内の名前変更リセット機能が @fouteox によって追加されました。
- `class "string" not found` というバグが @joshhanley によって修正されました。
新しいコントリビューター:
- @fouteox が初めて貢献しました。
完全な変更履歴はこちらから確認できます: https://github.com/livewire/livewire/compare/v3.3.2...v3.3.3
#laravel
### Laravel FAQs
#### Q: Laravelで始めるには、どんな要件がありますか?
A: Laravelを始めるにあたり、以下の要件が必要です。
- Webサーバー: ApacheまたはNginxが推奨されます。
- PHPのバージョン: Laravelのバージョンによって異なりますが、基本的には最新の安定版を使用することを推奨します。
- Composer: PHPの依存関係マネージャーであり、Laravelプロジェクトの作成と管理には必須です。
- データベース: MySQL、PostgreSQL、SQLite、SQL Serverのいずれかをサポートしています。
- より詳しい情報やバージョンに関する指針は、Laravelの公式ドキュメントを参照してください。
#laravel
tailwindlabs/tailwindcss v3.4.0
https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.4.0
Tailwind CSS v3.4がリリースされました。新機能やハイライトについては、[発表記事](https://tailwindcss.com/blog/tailwindcss-v3-4)をご覧ください。
### 追加された機能
- デフォルトの`height`/`min-height`/`max-height`テーマに`svh`、`lvh`、`dvh`の値を追加 ([#11317](https://github.com/tailwindlabs/tailwindcss/pull/11317))
- `:has(...)`疑似クラスに対する`has-*`バリアントを追加 ([#11318](https://github.com/tailwindlabs/tailwindcss/pull/11318))
- `text-wrap`ユーティリティに`text-balance`と`text-pretty`を含む ([#11320](https://github.com/tailwindlabs/tailwindcss/pull/11320), [#12031](https://github.com/tailwindlabs/tailwindcss/pull/12031))
- デフォルトの`opacity`スケールを5刻みの全ステップに拡張 ([#11832](https://github.com/tailwindlabs/tailwindcss/pull/11832))
- Preflightの`html`スタイルを更新し、shadow DOMの`:host`疑似クラスを含むように ([#11200](https://github.com/tailwindlabs/tailwindcss/pull/11200))
- `grid-rows-*`ユーティリティのデフォルト値を1–6から1–12に増加 ([#12180](https://github.com/tailwindlabs/tailwindcss/pull/12180))
- `size-*`ユーティリティを追加 ([#12287](https://github.com/tailwindlabs/tailwindcss/pull/12287))
- CSSサブグリッド用のユーティリティを追加 ([#12298](https://github.com/tailwindlabs/tailwindcss/pull/12298))
- `min-w-*`、`min-h-*`、`max-w-*`ユーティリティにスペーシングスケールを追加 ([#12300](https://github.com/tailwindlabs/tailwindcss/pull/12300))
- `forced-color-adjust`ユーティリティを追加 ([#11931](https://github.com/tailwindlabs/tailwindcss/pull/11931))
- `forced-colors`バリアントを追加 ([#11694](https://github.com/tailwindlabs/tailwindcss/pull/11694), [#12582](https://github.com/tailwindlabs/tailwindcss/pull/12582))
- `appearance-auto`ユーティリティを追加 ([#12404](https://github.com/tailwindlabs/tailwindcss/pull/12404))
- `float`と`clear`ユーティリティに論理プロパティ値を追加 ([#12480](https://github.com/tailwindlabs/tailwindcss/pull/12480))
- 直接の子要素を対象とする`*`バリアントを追加 ([#12551](https://github.com/tailwindlabs/tailwindcss/pull/12551))
### 変更された機能
- `sans`フォントファミリースタックを簡素化 ([#11748](https://github.com/tailwindlabs/tailwindcss/pull/11748))
- iOSでのタップハイライトオーバーレイを無効化 ([#12299](https://github.com/tailwindlabs/tailwindcss/pull/12299))
- `rtl`、`ltr`、`forced-colors`、`dark`バリアントの相対的な優先順位を改善 ([#12584](https://github.com/tailwindlabs/tailwindcss/pull/12584))
#laravel
livewire/livewire v3.3.2
https://github.com/livewire/livewire/releases/tag/v3.3.2
次のリリースノートの要約は以下の通りです。
変更点:
- `assertHasErrors`の修正が@nuernbergerAによって行われました。詳細はこちらのプルリクエストで確認できます: https://github.com/livewire/livewire/pull/7573
完全な変更履歴はこちらから確認できます: https://github.com/livewire/livewire/compare/v3.3.1...v3.3.2
#laravel
livewire/livewire v3.3.1
https://github.com/livewire/livewire/releases/tag/v3.3.1
リリースノートの変更点を以下に要約します。
### 変更された点
- ページコンポーネント上の認証ミドルウェアを修正しました。(@calebporzioによる貢献)
- スクリプト実行後のイベントディスパッチを処理するようにしました。(@calebporzioによる貢献)
- `assertHasError`を追加しました。(@jasonmccrearyによる貢献)
- フォームオブジェクトのプロパティに#[Url]をサポートしました。(@calebporzioによる貢献)
- コマンド説明から末尾のピリオドを削除しました。(@dwightwatsonによる貢献)
- `volt.md`の検索例にリアルタイム更新を有効にしました。(@osbreによる貢献)
- 配列の更新フックに関するドキュメントを作成しました。(@ramonrietdijkによる貢献)
- #[Url]プロパティに対するenumサポートを追加しました。(@calebporzioによる貢献)
### 新しい貢献者
- @jasonmccrearyが初めて貢献しました。
- @osbreが初めて貢献しました。
**完全な変更履歴**: https://github.com/livewire/livewire/compare/v3.3.0...v3.3.1
#laravel
laravel/jetstream v4.2.0
https://github.com/laravel/jetstream/releases/tag/v4.2.0
このリリースノートは、Laravel Jetstreamのプルリクエストに関するもので、次のように要約できます:
- Laravel Jetstreamのバージョン4.xにおいて、@timacdonaldによってViteバージョン5へのアップデートが行われました。
- この変更はGitHubのプルリクエスト番号1418で確認できます。
Viteはフロントエンドのビルドツールであり、このアップデートはJetstreamを使用する開発者にとって、フロントエンドのビルドプロセスに関する重要な変更を意味しています。
#laravel
laravel/breeze v1.27.0
https://github.com/laravel/breeze/releases/tag/v1.27.0
- @TENIOSによってPostCSSのバージョンが更新されました(https://github.com/laravel/breeze/pull/339)。
- @lucidpolygonがLivewire関数からモーダルを閉じるための`x-on:close-modal.window`ディレクティブを追加しました(https://github.com/laravel/breeze/pull/341)。
- InertiaスタックでのZiggy設定が@bakerkretzmarによって改善されました(https://github.com/laravel/breeze/pull/340)。
- @timacdonaldによってVite 5が[1.x]ブランチに導入されました(https://github.com/laravel/breeze/pull/342)。
#laravel
laravel/laravel v10.3.0
https://github.com/laravel/laravel/releases/tag/v10.3.0
次のリリースノートの要約は以下の通りです:
- Laravel 10.xバージョンでは、テストで`assertStatus(200)`の代わりに`assertOk()`を使用するように変更されました。この変更は、https://github.com/laravel/laravel/pull/6287 で@TENIOSによって提案されました。
- Laravel 10.xバージョンでは、Viteのバージョンが5にアップデートされました。この変更は、https://github.com/laravel/laravel/pull/6292 で@timacdonaldによって行われました。
#laravel
laravel/framework v10.38.0
https://github.com/laravel/framework/releases/tag/v10.38.0
Laravelの10.xバージョンに関するリリースノートの要約は以下の通りです。
- テストリクエストに`routeRoute`メソッドを追加しました。
- インポートの更新とタイポの修正を行いました。
- `db:table`コマンドでデフォルトの`false`値を表示するようにしました。
- `sql_require_primary_key`が有効なMySQLでのプライマリーキー作成の問題を修正しました。
- `Blueprint`に`charset`と`collation`メソッドを追加しました。
- Octaneで`about`コマンドを2回実行した際の問題を修正しました。
- ArrayLockの`getCurrentOwner`に関するバグを修正しました。
- Dynamo Batch RepositoryでHorizonのデフォルトのソートに合わせました。
- Bladeに`@session`ディレクティブを追加しました。
- `Arr::dot`のパフォーマンスを向上させました。
- `assertStatus()`のパラメータ順序の問題を修正しました。
- `defaultCasters`が以前に設定されていない場合のみ設定するようにしました。
- `ManagesFrequencies`のパラメータタイプの問題を修正しました。
- `whereJsonContains`メソッドにSQLiteサポートを追加しました。
- Validationでネイティブの`json_validate`を使用するようにしました。
- `ComponentAttributeBag`に`isEmpty`と`isNotEmpty`を導入しました。
- 新しいプライマリーキーを追加する際に、既存のプライマリーキーがあれば削除するようにしました。
- スキーマビルダーの`getColumns()`メソッドを改善しました。
- プレーンテキストのメール通知用に`MailMessage`ヘルパーを追加しました。
- テストの改善を行いました。
- PipelineにConditionableを追加しました。
これらの変更は、Laravelフレームワークの機能強化やバグ修正、パフォーマンス向上などを目的としています。各項目はGitHubのプルリクエストにリンクされており、詳細な変更内容を確認することができます。
#laravel
Question:
In Laravel, is it possible to define a route that only responds to requests coming from within the application itself, effectively creating an "internal only" endpoint, and if so, how might one implement this peculiar behavior without relying on middleware checks for the originating request's IP?
Answer:
Typically, routes in Laravel are publicly accessible as long as a client can reach the server, and developers use middleware to restrict access. An "internal only" endpoint would be unusual since HTTP inherently allows clients from different origins.
However, you can create a conceptually "internal only" endpoint by checking the Referer header against your application's URL or by handling a specific custom header that your internal requests would carry.
Here's how to do this without traditional middleware but inline within the route definition:
```php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('/internal-endpoint', function (Request $request) {
$internalSecret = env('INTERNAL_REQUEST_SECRET');
$providedSecret = $request->header('Internal-Request-Secret');
if ($internalSecret !== $providedSecret) {
abort(403);
}
// Your internal endpoint logic here
})->name('internal-only');
```
This example expects an 'Internal-Request-Secret' header with a value that matches an environment variable named 'INTERNAL_REQUEST_SECRET'. This is not a standard security practice and should not replace proper authentication and authorization mechanisms.
Be warned that this implementation, while unusual, is not particularly secure. It relies on a shared secret sent via headers, which could be intercepted and seen by anyone with access to the network traffic (if not using HTTPS) or the application's environment. It's essential to consider security implications and perhaps only use this for non-critical, internal microservices communication, combined with other security layers such as network restrictions or VPNs.
#laravel