Revision 1633 | Revision 1635 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpnamespace App\Console\Commands;use Illuminate\Console\Command;use App\Models\PriceAgency;class dump extends Command{/*** The name and signature of the console command.** @var string*/protected $signature = 'command:dump';/*** The console command description.** @var string*/protected $description = 'Erstellt CSV-Dateien für Preisagenturen';/*** Execute the console command.** @return void*/public function handle(): void{$items = Item::with( 'price', 'medium.medium', "manufacturer" )->where( 'status', 0 )->get();$agencies = PriceAgency::where( 'shop_id', $GLOBALS["INI"]["shops_ID"] )->where( "status", "1" )->get();foreach ( $agencies as $agency ){$content = array();$this->info( $agency["name"] );if ( !$agency["config"] ){$this->warn( "Agentur nicht komplett konfiguriert!" );continue;}$configFile = storage_path( "config/" ) . $agency["config"];if ( file_exists( $configFile ) ){require $configFile;}else{$this->error( "Konfigdatei " . $configFile . " existiert nicht!" );continue;}$fName = basename( parse_url( $agency["csv_url"], PHP_URL_PATH ) );$fName = storage_path() . "/" . $fName;$f = fopen( $fName, "w" );foreach ( $items as $item ){foreach ( $content as $c ){list( $col, $required ) = $c;// Inhalt ist vorhanden oder muss ausgewertet werden?if ( isset( $item->$col ) ){$col = $item->$col;}elseif ( !stristr( $col, "return" ) ){$col = "";}else{$col = @eval( $col );}// Inhalt mit required vergleichen/*requiredtrue: Wert muss vorhanden seinfalse: Wert muss nicht vorhanden seinstring: Ausdruck muss string ergeben*/if ( is_bool( $required ) ){if ( ( $required === true ) && ( !$col ) ){continue 2;}}else{if ( !@eval( $required ) ){continue 2;}}$buffer[] = $quote . $col . $quote;} // foreachfwrite( $f, implode( $trenner, $buffer ) . "\n" );}fclose( $f );}}}