From c2ad1b08cef229cf1ccffff6ebf2d73212535d17 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa Date: Fri, 2 May 2025 22:05:39 +0300 Subject: [PATCH] Remove trailing whitespace and final new lines --- api.md | 14 +++++++------- auth.md | 2 +- collections.md | 1 - db-models-and-eloquent.md | 4 ++-- factories.md | 1 - log-and-debug.md | 2 +- mail.md | 1 - migrations.md | 9 ++++----- models-relations.md | 1 - other.md | 3 +-- routing.md | 1 - validation.md | 1 - views.md | 1 - 13 files changed, 16 insertions(+), 25 deletions(-) diff --git a/api.md b/api.md index 5b7d0d2..de40db0 100644 --- a/api.md +++ b/api.md @@ -238,7 +238,7 @@ public function handle($request, Closure $next) Second, register the created middleware in app/Http/Kernel.php file: ```php -protected $middlewareGroups = [ +protected $middlewareGroups = [ 'api' => [ \App\Http\Middleware\ForceJsonResponse::class, ], @@ -255,12 +255,12 @@ Tip given by [Feras Elsharif](https://github.com/ferasbbm) If you are working on a project that may have multi-release in the future or your endpoints have a breaking change like a change in the format of the response data, and you want to ensure that the API version remains functional when changes are made to the code. -#### Change The Default Route Files +#### Change The Default Route Files The first step is to change the route map in the `App\Providers\RouteServiceProvider` file, so let's get started: #### Laravel 8 and above: -Add a 'ApiNamespace' property +Add a 'ApiNamespace' property ```php /** @@ -279,7 +279,7 @@ $this->routes(function () { ->namespace($this->ApiNamespace.'\\V1') ->group(base_path('routes/API/v1.php')); } - + //for v2 Route::prefix('api/v2') ->middleware('api') @@ -304,7 +304,7 @@ protected string $ApiNamespace = 'App\Http\Controllers\Api'; Inside the method map, add the following code: ```php -// remove this $this->mapApiRoutes(); +// remove this $this->mapApiRoutes(); $this->mapApiV1Routes(); $this->mapApiV2Routes(); ``` @@ -345,8 +345,8 @@ Controllers ``` routes └── Api - │ └── v1.php - │ └── v2.php + │ └── v1.php + │ └── v2.php └── web.php ``` diff --git a/auth.md b/auth.md index 8f503ba..5120573 100644 --- a/auth.md +++ b/auth.md @@ -122,7 +122,7 @@ Gate::before(function (?User $user, $ability) { Laravel's authentication system fires various events during the authentication process, allowing you to hook into these events and perform additional actions or custom logic. -For example, you might want to log users Login. +For example, you might want to log users Login. You can achieve this by listening to the `Illuminate\Auth\Events\Login` event. To implement it: diff --git a/collections.md b/collections.md index 57314bb..41fdb07 100644 --- a/collections.md +++ b/collections.md @@ -144,4 +144,3 @@ Collection::times(7, function ($number) { ``` Tip given by [@Teacoders](https://twitter.com/Teacoders/status/1509447909602906116) - diff --git a/db-models-and-eloquent.md b/db-models-and-eloquent.md index 354bc80..2d81575 100644 --- a/db-models-and-eloquent.md +++ b/db-models-and-eloquent.md @@ -2199,14 +2199,14 @@ class CategoryController extends Controller { // instead of $category = Category::where('name', $request->name)->first(); - + if (!$category) { $category = Category::create([ 'name' => $request->name, 'slug' => Str::slug($request->name), ]); } - + // you can use $category = Category::firstOrCreate([ 'name' => $request->name, diff --git a/factories.md b/factories.md index 94ec6ed..67db314 100644 --- a/factories.md +++ b/factories.md @@ -141,4 +141,3 @@ class EventSeeder extends Seeder ``` Tip given by [@justsanjit](https://twitter.com/justsanjit/status/1514428294418079746) - diff --git a/log-and-debug.md b/log-and-debug.md index d33bb60..7cdd90e 100644 --- a/log-and-debug.md +++ b/log-and-debug.md @@ -120,7 +120,7 @@ If you want to implement a new listener to a specific event but you don't know i You can use the `\Illuminate\Support\Facades\Event::listen()` method on `boot()` method of `app/Providers/EventServiceProvider.php` to catch all events fired. -**Important:** If you use the `Log` facade within this event listener then you will need to exclude events named `Illuminate\Log\Events\MessageLogged` to avoid an infinite loop. +**Important:** If you use the `Log` facade within this event listener then you will need to exclude events named `Illuminate\Log\Events\MessageLogged` to avoid an infinite loop. (Example: `if ($event == 'Illuminate\\Log\\Events\\MessageLogged') return;`) ```php diff --git a/mail.md b/mail.md index 3aa4eb8..ec233e1 100644 --- a/mail.md +++ b/mail.md @@ -110,4 +110,3 @@ class InvoicePaid extends Notification Use the `when` or `unless` methods in you own classes by using the `Illuminate\Support\Traits\Conditionable` trait Tip given by [@Philo01](https://twitter.com/Philo01/status/1503302749525528582) - diff --git a/migrations.md b/migrations.md index a2c67ae..c83c270 100644 --- a/migrations.md +++ b/migrations.md @@ -70,10 +70,10 @@ If you want to check what migrations are executed or not yet, no need to look at Example result: ``` -Migration name .......................................................................... Batch / Status -2014_10_12_000000_create_users_table ........................................................... [1] Ran -2014_10_12_100000_create_password_resets_table ................................................. [1] Ran -2019_08_19_000000_create_failed_jobs_table ..................................................... [1] Ran +Migration name .......................................................................... Batch / Status +2014_10_12_000000_create_users_table ........................................................... [1] Ran +2014_10_12_100000_create_password_resets_table ................................................. [1] Ran +2019_08_19_000000_create_failed_jobs_table ..................................................... [1] Ran ``` ### Create Migration with Spaces @@ -302,4 +302,3 @@ Schema::create('posts', function (Blueprint $table) { ``` Tip given by [@iamgurmandeep](https://twitter.com/iamgurmandeep/status/1517152425748148225) - diff --git a/models-relations.md b/models-relations.md index 1578ed4..2140c3a 100644 --- a/models-relations.md +++ b/models-relations.md @@ -680,4 +680,3 @@ select * from posts where user_id = ? and (active = 1 or votes >= 100) ``` Tip given by [@BonnickJosh](https://twitter.com/BonnickJosh/status/1494779780562096139) - diff --git a/other.md b/other.md index f6a55d0..c0b8042 100644 --- a/other.md +++ b/other.md @@ -112,7 +112,7 @@ class TerminatingMiddleware { return $next($request); } - + public function terminate($request, $response) { // ... @@ -1522,4 +1522,3 @@ If you ever need to bypass database when a job fails, you can do one of the belo Why you would want this? For applications where you do not need to store failed jobs and they needs to have very high TPS, skipping database can be very favourable as we are not hitting database, saving times & prevent database going down. Tip given by [@a-h-abid](https://github.com/a-h-abid) - diff --git a/routing.md b/routing.md index bdd5e76..4ec52b6 100644 --- a/routing.md +++ b/routing.md @@ -674,4 +674,3 @@ Route::controller(UsersController::class)->group(function () { ``` Tip given by [@justsanjit](https://twitter.com/justsanjit/status/1514943541612527616) - diff --git a/validation.md b/validation.md index 0602268..50c9105 100644 --- a/validation.md +++ b/validation.md @@ -521,4 +521,3 @@ class RegistrationController extends Controller ``` Tip given by [@mattkingshott](https://twitter.com/mattkingshott/status/1518590652682063873) - diff --git a/views.md b/views.md index e996515..ac841dd 100644 --- a/views.md +++ b/views.md @@ -433,4 +433,3 @@ This is going to be a nice addition that we can use to clean up our Blade views ``` Tip given by [@VijayGoswami](https://vijaygoswami.in) -