Support the ongoing development of →
Database Eloquent
Last updated 2 years ago.

Do you extend Eloquent?

class Confirm extends Eloquent {
Last updated 2 years ago.

Can we see the database too?

Maybe this helps

$posts = Confirm::with('posts')->where('reply_user_id','=',Auth::user()->id)->get();
Last updated 2 years ago.

Thanks for the replies

these are my tables..

 users: id name
 post:id  post user_id
 reply:id reply post_id
 confirm:id message reply_id post_id reply_user_id...

I'm trying to display all the posts by their post_id present in confirm table and that have reply_user_id=Auth::user()->id. Above query returns confirm object.Please provide me the solun. Thanks..

Last updated 2 years ago.

This is not the best solution as it will do multiple queries

$post_ids = Confirm::select('post_id')->where('reply_user_id','=',Auth::user()->id)->get()->toArray();
$post_ids = flatten($post_ids);
$posts = Post::whereIn('id',$post_ids);

function to flatten the array

function flatten(array $array) {
	$return = array();
	array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
	return $return;


DB::table('confirm AS c')
            ->join('post AS p', 'c.post_id', '=', '')
Last updated 2 years ago.


I'm using this query

                       $post = DB::select('select from post AS p,confirm AS c where AND                                                     c.reply_user_id='.Auth::user()->id.'');

This worked for me.

Thank you.

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.