
How to get list of all views file in laravel
-
Get all files of views directory in array
//config\filesystems.php 'disks' => [ 'views' => [ 'driver' => 'local', 'root' => base_path('resources/views'), ], ], //Code to get the list of all view files. $files = Storage::disk('views')->files(''); echo "<pre>"; print_r($files); //Import storage facade before calling the disk method on Storage facade. use Illuminate\Support\Facades\Storage;
0You can get a list of all views files in laravel using this code snippet. This code snippet returns the files name in an array using the disk(‘views’)->files() method on Storage Facades. Use
use Illuminate\Support\Facades\Storage;
to call Storage fasade in your controller file. It only returns the files name which are directly inside of the views directory.Array
(
[0] => bsform.blade.php
[1] => get-ajax.blade.php
[2] => home.blade.php
[3] => posts.blade.php
[4] => welcome.blade.php
) -
Get all files within a views directory including all sub-directories
//config\filesystems.php 'disks' => [ // ... 'views' => [ 'driver' => 'local', 'root' => base_path('resources/views'), ], ], // app\Http\Controllers\<YourController>.php $files = Storage::disk('views')->allFiles(''); echo "<pre>"; print_r($files);
0This code snippet returns an array of all files within a given directory (views) including all sub-directories. Basically this method returns all the files which are directly inside of the views directory or in its sub-directory in laravel. Here index.blade.php is the file under image directory which is a sub-directory of views directory.
Array
(
[0] => bsform.blade.php
[1] => get-ajax.blade.php
[2] => home.blade.php
[3] => image/index.blade.php
[4] => posts.blade.php
[5] => welcome.blade.php
)
Random Code Snippet Queries: Laravel
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement
- Extra Filter Query on Relationships in Laravel
- How to create project_user pivot table in laravel
- How to Access Array in blade laravel
- How to check records exist in loaded relationship in Laravel blade view
- Generate random string lowercase in Laravel
- Global scope in Laravel with example
- Add a subselect based on relationship using withAggregate method
- How to insert value to additional columns in pivot table in laravel
- How to pass external link in laravel blade to anchor tag
- Validation errors for multiple forms on same page Laravel
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- Non-static method App\Http\Helper::myFunction() should not be called statically
- How to update record after save method in Laravel
- Seed database using SQL file in Laravel
- How to return error message from controller to view in laravel
- Laravel pagination links with query string
- Remove public from url in laravel project
- How to insert ckeditor data into database in Laravel?
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- Permanently delete a record in laravel
- SQLSTATE[42000]: Syntax error or access violation: 1055
- Get Array of IDs from Eloquent Collection
- Retain selected value of select box in Laravel
- How to get last record from object collection in laravel