skip to Main Content

sql query last_messages displays wrong message – Laravel

i have query like this, but displays wrong last_message. $users = Message::join('users', function ($join) { $join->on('messages.from_id', '=', 'users.id') ->orOn('messages.to_id', '=', 'users.id'); }) ->where(function ($q) { $q->where('messages.from_id', auth()->user()->id) ->orWhere('messages.to_id', auth()->user()->id); }) ->where('users.id','!=',auth()->user()->id) ->select([ 'users.id', 'users.name', 'users.avatar', DB::raw('MAX(messages.created_at) max_created_at'), DB::raw('MAX(messages.body) last_message'), DB::raw('CASE…

VIEW QUESTION

Flickity AsNavFor producing error in the console: "Uncaught TypeError: Cannot read properties of undefined (reading 'create')" – Laravel

i'm using flickity as the instructions, but got this error warning in the console anybody know how to solve this? Here is the current bundle package <script src="https://unpkg.com/flickity-as-nav-for@3/as-nav-for.js"></script> <script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css"> i'm using flickity AsNavFor but it shown…

VIEW QUESTION

Laravel eloquent multiple WHERE

I'm new in php/laravel. I'm trying to get one user with the userName of the user connected except if it's "Chuck NORRIS" This, is working. I'm getting the user connected information $oneUser= User::where('name', $userName)->get(); This, is not working. I'm getting…

VIEW QUESTION
Back To Top
Search