Updating Translations from the Command Line

Hi all, as usual I assume I'm misunderstanding something basic about how Laravel works, but I have been stuck trying to update existing translations directly with data from a Console Command. I'm trying to back-fill some missing information that I'm scraping from HTML files. I have tried several different combinations of querying the database to get the existing record and updating it, but nothing seems to work. I can verify that the entry I'm trying to update exists in the database, but when I try to update() or save() I just don't get any results, and don't get any errors. This is my current attempt to query out the existing entries. Not sure how to update the model that this returns.
$existingProduct = Product::join('product_translations', 'products.id' , '=', 'product_translations.product_id')
->where('title', $productTitle)
->where('locale', 'en')
->where('products.deleted_at', null)
->where('product_translations.deleted_at', null)
->where('brand_id', $brandId)
->first();
$existingProduct = Product::join('product_translations', 'products.id' , '=', 'product_translations.product_id')
->where('title', $productTitle)
->where('locale', 'en')
->where('products.deleted_at', null)
->where('product_translations.deleted_at', null)
->where('brand_id', $brandId)
->first();
2 Replies
daniel
danielOP2y ago
I tried to update using this and it didn't work:
$existingProduct = ProductTranslation::where('title', $productTitle)
->where('locale', 'en')
->where('product_translations.deleted_at', null)
->update([
'specifications' => $specsHtml,
'features' => $featureHtml,
]);
$existingProduct = ProductTranslation::where('title', $productTitle)
->where('locale', 'en')
->where('product_translations.deleted_at', null)
->update([
'specifications' => $specsHtml,
'features' => $featureHtml,
]);
ok, thankfully i'm an idiot... in my test case the actual HTML i was sending to update was blank
Want results from more Discord servers?
Add your server