Query is not giving proper translated data

lckamal - 2 weeks ago

Is there something wrong in this query?

FaqModel::select('faqs_faqs_translations.locale','faqs_faqs_translations.answer','faqs_faqs_translations.entry_id', 'faqs_faqs.*')->join('faqs_faqs_translations', 'faqs_faqs_translations.entry_id', 'faqs_faqs.id')
            ->where('faqs_faqs_translations.locale', LOCALE)
            ->get();

Here is output when I call api url: http://almidan.dev/en/api/faq

Data looks like this:

{
    "status": 1,
    "token": null,
    "message": "Success",
    "data": [
        {
            "locale": "en",
            "question": "ما هي رسوم استخدام الميدان؟ ",
            "answer": "الميدان مجانا لاي مستخدم. ",
            "entry_id": 51,
            "id": 51,
            "sort_order": 41,
            "created_at": "2017-05-17 05:15:27",
            "created_by_id": 1,
            "updated_at": null,
            "updated_by_id": null,
            "deleted_at": null,
            "category_id": 2,
            "live": 1
        },
     ...
}

http://take.ms/8CITq

piterden - 2 weeks ago

    /**
     * Add a join clause to the query.
     *
     * @param  string  $table
     * @param  string  $one
     * @param  string  $operator
     * @param  string  $two
     * @param  string  $type
     * @param  bool    $where
     * @return $this
     */
    public function join($table, $one, $operator = null, $two = null, $type = 'inner', $where = false)

lckamal - 2 weeks ago

This model query doesn't work:

$faqs = FaqModel::select('faqs_faqs.*', 'faqs_faqs_translations.locale','faqs_faqs_translations.question','faqs_faqs_translations.answer','faqs_faqs_translations.entry_id')
            ->join('faqs_faqs_translations', 'faqs_faqs_translations.entry_id', '=', 'faqs_faqs.id')
            ->where('faqs_faqs_translations.locale', '=', LOCALE)
            ->groupBy('faqs_faqs_translations.entry_id')
            ->get()->toArray();

This db query works:

$faqs = \DB::table('faqs_faqs_translations')
            ->select('faqs_faqs.*', 'faqs_faqs_translations.locale','faqs_faqs_translations.question','faqs_faqs_translations.answer','faqs_faqs_translations.entry_id')
            ->join('faqs_faqs', 'faqs_faqs_translations.entry_id', '=', 'faqs_faqs.id')
            ->where('faqs_faqs_translations.locale', '=', LOCALE)
            ->groupBy('faqs_faqs_translations.entry_id')
            ->get()->toArray();

something wrong on model translations on core?

This video can explain more: http://take.ms/WTU4V