fix pdf methoth not showing, add in ObjekteImDetail projekt_methode_id for relation (kick out raumart for relation)
This commit is contained in:
1 parent
d95452bc9d
commit
fe826c3bab
8 files changed
+203
-37
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Projekte;
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixMethodRelations extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* app:fix-method-relations
|
||||
*/
|
||||
protected $signature = 'app:fixdb1 {--d}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix relation in table "projekt_objekte_im_details" mit "projekt_methodes" id';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Notice::note('Start FixMethodRelations', 'b');
|
||||
|
||||
$projekte = Projekte::get();
|
||||
|
||||
foreach ($projekte as $projekt) {
|
||||
|
||||
$projektid = $projekt->id;
|
||||
|
||||
$methoden = ProjektMethode::where('projekte_id', $projektid)->pluck('id', 'raumart')->toArray();
|
||||
|
||||
$res = ProjektObjekteImDetail::where('projekte_id', $projektid)->get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
|
||||
if (! $value->projekt_methode_id) {
|
||||
|
||||
if (isset($methoden[$value->raumart])) {
|
||||
$projekt_methode_id = $methoden[$value->raumart];
|
||||
|
||||
ProjektObjekteImDetail::where('id', $value->id)->update(['projekt_methode_id' => $projekt_methode_id]);
|
||||
} else {
|
||||
Notice::note('Error: Methode für Raumart '.$value->raumart.' in Projekt'.$projekt->interner_name.' Id '.$projekt->id.' Methode missing', 'r');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user