D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
school.dentostock.com
/
app
/
Console
/
Commands
/
Filename :
ClearLogFilesCommand.php
back
Copy
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; class ClearLogFilesCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'clear:log-files'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $files = Arr::where(Storage::disk('log')->files(), function($filename) { return Str::endsWith($filename,'.log'); }); $count = count($files); if(Storage::disk('log')->delete($files)) { $this->info(sprintf('Deleted %s %s!', $count, Str::plural('file', $count))); } else { $this->error('Error in deleting log files!'); } } }