New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I get only the "title" column, excluding the "content" column? #343
Comments
This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days |
hello, any updates and answers? |
Hi, I found your question because I had a similar issue. To avoid loading unnecessary columns, you can add disableAutoloadTranslations() to the constructor of your model:
If you want to disable autoload globally, you can change this translatable.php setting to false: Refer to: https://docs.astrotomic.info/laravel-translatable/package/methods#translation-autoloading |
Hi @omarcinkonis . Thanks for your reply. Now I use that code: Article::query()
->with('translations', function ($query) {
$query
->select(['article_id', 'locale', 'title']) // without 'content' because it's too big
->where('locale', app()->getLocale());
})
->paginate(); After that, I wrap it in ArticleResource, there I already bring it to the form I need. |
Good afternoon!
I have a table of
articles
andarticle_translations
.article_translations
contains two translatable columnstitle
andcontent
. Thecontent
column can contain more than 10,000 characters. To get all thearticles
I do this:and this code get all translated columns, including
content
, but thecontent
column is not needed, and loads the requestHow do I get only the
title
column, excluding thecontent
column?The text was updated successfully, but these errors were encountered: