Колонка не найдена: - PullRequest
       0

Колонка не найдена:

0 голосов
/ 29 января 2020
public function AddWishlist($id)
{
    $userid = Auth::id();
    $check = DB::table('whishlists')
        ->where('user_id', $userid)
        ->where('whishlists', $id)
        ->first();

    $data = ['user_id' => $userid, 'product_id' => $id];

    if (Auth::check())
    {
        if ($check)
        {
            $notification = ['messege' => 'already added whisahlist', 'alert-type' => 'error'];

            return redirect()->back()->with($notification);
        }
        else
        {
            DB::table('whishlists')->insert($data);
            $notification = [
                'messege'    => 'Suucessafully added whisahlist',
                'alert-type' => 'success'
            ];

            return redirect()->back()->with($notification);
        }

    }
    else
    {
        $notification = array(
            'messege'    => 'At first login your account',
            'alert-type' => 'error'
        );

        return redirect()->back()->with($notification);
    }
}

Проблема

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'whishlists' in 'where clause' (SQL: select * from `whishlists` where `user_id` = 1 and `whishlists` = 37 limit 1)

1 Ответ

1 голос
/ 29 января 2020

лог c будет меняться

->where('whishlists', $id)

с

->where('whishlist_id', $id)

, если он не работает, пожалуйста, покажите нам таблицы с таблицами

Примечание:

если $ id является идентификатором списка желаний, я думаю, что эту строку следует пересмотреть:

$data = ['user_id' => $userid, 'product_id' => $id];

, поскольку для него установлен 'product_id' с идентификатором списка желаний

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...