Fast Log add tenant
This commit is contained in:
parent
18b6fb6807
commit
484bcc236e
2 changed files with 26 additions and 6 deletions
|
@ -14,14 +14,12 @@ class Access {
|
|||
throw new \Exception("Invalide Typ for Access Log");
|
||||
}
|
||||
|
||||
$this->addAccessLog(null, null, $image->id, $typ, $file->getSize());
|
||||
$this->addAccessLog($image->tenant, null, $image->id, $typ, $file->getSize());
|
||||
}
|
||||
|
||||
public function addById(int $image_id, File $file, string $typ) {
|
||||
if(!in_array($typ, $this->valideTyps)) {
|
||||
throw new \Exception("Invalide Typ for Access Log");
|
||||
}
|
||||
$this->addAccessLog(null, null, $image_id, $typ, $file->getSize());
|
||||
$image = \App\Models\Image::query()->where("id", "=", $image_id)->firstOrFail();
|
||||
$this->add($image, $file, $typ);
|
||||
}
|
||||
|
||||
public function addComplete(\App\Models\Image $image, Gallery $gallery, Tenant $tenant, File $file, string $typ) {
|
||||
|
|
|
@ -15,12 +15,34 @@ class FastAccessLog extends Migration
|
|||
{
|
||||
Schema::table("access", function(Blueprint $table) {
|
||||
$table->unsignedBigInteger("gallery")->nullable()->change();
|
||||
$table->unsignedBigInteger("tenant")->nullable()->change();
|
||||
//$table->unsignedBigInteger("tenant")->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table("traffic", function(Blueprint $table) {
|
||||
$table->unsignedBigInteger("gallery")->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table("images", function (Blueprint $table) {
|
||||
$table->unsignedBigInteger("tenant");
|
||||
});
|
||||
|
||||
$images = \App\Models\Image::query()->get();
|
||||
foreach ($images as $image) {
|
||||
if(is_null($image->gallery)) {
|
||||
$image->tenant = 1;
|
||||
$image->saveOrFail();
|
||||
} else {
|
||||
$gallery = \App\Models\Gallery::query()->where("id", "=", $image->gallery)->firstOrFail();
|
||||
$image->tenant = $gallery->tenant;
|
||||
$image->saveOrFail();
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table("images", function (Blueprint $table) {
|
||||
$table->foreign('tenant')->references('id')->on('tenants');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue