Laravel 8.76 のヒント
5309 ワード
早速始めましょう
あなたに役立つと思われるヒントを見つけました.
移行を実行した直後にテストでデータをシードする場合に、テストで使用できる afterRefreshingDatabase メソッド
禁止された()および許可されていないメソッドをResponseクラスに追加します.これらのメソッドは、これらのステータスに関するロジックを適切にクリーンアップします
MySQL v8.0.23 で導入された invisible 修飾子のサポート.列が非表示としてマークされている場合、それらは暗黙的に (つまり、SELECT *) ではなく、したがって Laravel モデルで水和されません.これらの列は引き続き明示的に選択できるため、データが明示的に必要でない限り省略すると便利です
https://dev.mysql.com/doc/refman/8.0/en/invisible-columns.html
最後に :- substrReplace() を Str および Stringable クラスに
コードを楽しんでいただければ幸いです.
ソース :- https://laravel-news.com/laravel-8-76-0
あなたに役立つと思われるヒントを見つけました.
移行を実行した直後にテストでデータをシードする場合に、テストで使用できる afterRefreshingDatabase メソッド
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;
protected function afterRefreshingDatabase()
{
$this->artisan('db:seed', [
'--class' => RoleAndPermissionSeeder::class
]);
}
}
禁止された()および許可されていないメソッドをResponseクラスに追加します.これらのメソッドは、これらのステータスに関するロジックを適切にクリーンアップします
// Before
if ($response->status() === 401) {
// ...
}
if ($response->status() === 403) {
// ...
}
// After
if ($response->unauthorized()) {
// ...
}
if ($response->forbidden()) {
// ...
}
MySQL v8.0.23 で導入された invisible 修飾子のサポート.列が非表示としてマークされている場合、それらは暗黙的に (つまり、SELECT *) ではなく、したがって Laravel モデルで水和されません.これらの列は引き続き明示的に選択できるため、データが明示的に必要でない限り省略すると便利です
https://dev.mysql.com/doc/refman/8.0/en/invisible-columns.html
Schema::table('users', function (Blueprint $table) {
$table->string('secret')->nullable()->invisible();
});
最後に :- substrReplace() を Str および Stringable クラスに
// Insert a string at a certain position
$string = '1300';
$result = Str::substrReplace($string, ':', 2, 0);
// '13:00'
// Replace the remainder of a string
$result = (string) Str::of('Laravel Framework')
->substrReplace('– The PHP Framework for Web Artisans', 8);
// 'Laravel – The PHP Framework for Web Artisans'
コードを楽しんでいただければ幸いです.
ソース :- https://laravel-news.com/laravel-8-76-0
Reference
この問題について(Laravel 8.76 のヒント), 我々は、より多くの情報をここで見つけました https://dev.to/morcosgad/some-tip-for-laravel-876-1ep3テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol