Get all files except specific paths in Laravel
Constantin Druc ยท 27 Mar, 2021
Recently I found myself in need of filtering out some paths when grabbing all the files using the File facade.
Those paths that need to be excluded can be specific files or specific directories. So we need to support both.
To save us from repeating the filtering logic everywhere, we can setup a macro.
Laravel macros allow us to add custom functionality to existing Laravel components. In our case, the File facade.
We can register a macro inside the Appservice provider, under the boot method.
-
1Blade scaffolding with Laravel Breeze05:21
-
2Cleaning up unused old records and files in Laravel applications06:22
-
Get all files except specific paths in Laravel09:41
-
4Authenticate mobile applications with Laravel Sanctum21:22
-
5Verify user emails in a Laravel REST API14:39
-
6The only reasonable, cost-effective way to test validation in Laravel applications06:53
-
7Setup live reload with Laravel mix and BrowserSync03:49
-
8Fetch and save Youtube video details in your Laravel application13:50
-
9Create more objects for more powerful and expressive code04:26
-
10Mock HTTP requests in Laravel05:38
-
11Create nested arrays using dot notation in Laravel06:39
-
12Use data providers to reduce test duplication08:56
-
13Add Github and Google authentication to your Laravel application16:32
-
14Calculate remaining days until birthday05:24
-
15Laravel SPA Authentication - setup and common mistakes16:37
-
16Serve Vue 3 applications using Laravel Valet04:18
-
17Laravel & Nuxt 3 Authentication Setup27:39
-
18Follow-up on Laravel and Nuxt 3 Authentication Guide08:15
-
19Setup Axios for Laravel API requests12:34
-
1Blade scaffolding with Laravel Breeze05:21
-
2Cleaning up unused old records and files in Laravel applications06:22
-
Get all files except specific paths in Laravel09:41
-
4Authenticate mobile applications with Laravel Sanctum21:22
-
5Verify user emails in a Laravel REST API14:39
-
6The only reasonable, cost-effective way to test validation in Laravel applications06:53
-
7Setup live reload with Laravel mix and BrowserSync03:49
-
8Fetch and save Youtube video details in your Laravel application13:50
-
9Create more objects for more powerful and expressive code04:26
-
10Mock HTTP requests in Laravel05:38
-
11Create nested arrays using dot notation in Laravel06:39
-
12Use data providers to reduce test duplication08:56
-
13Add Github and Google authentication to your Laravel application16:32
-
14Calculate remaining days until birthday05:24
-
15Laravel SPA Authentication - setup and common mistakes16:37
-
16Serve Vue 3 applications using Laravel Valet04:18
-
17Laravel & Nuxt 3 Authentication Setup27:39
-
18Follow-up on Laravel and Nuxt 3 Authentication Guide08:15
-
19Setup Axios for Laravel API requests12:34