-
app/Console/Commands/ClearLogs.php
Open in GitHubuse Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; class ClearLogs extends Command { // public function handle() { // $files = Storage::disk("logs")->allFiles(); $logFiles = collect($files)->mapWithKeys(function ($file) { $matches = []; $isMatch = preg_match("/^laravel\-(.*)\.log$/i", $file, $matches); if (count($matches) > 1) { $date = $matches[1]; } $key = $isMatch ? $date : ""; return [$key => $file]; })->forget(""); // } }
-
app/Http/Resources/DynamicAttributeCollection.php
Open in GitHubuse Illuminate\Database\Eloquent\Collection; use Illuminate\Http\Resources\Json\ResourceCollection; class DynamicAttributeCollection extends ResourceCollection { public static function toDictionary(Collection $collection): array { $keyed = $collection->mapWithKeys(function ($attr) { return [$attr['attribute_id'] => $attr['attribute_type']]; }); return $keyed->all(); } // }