you wanted to retrieve all other users who is having interests same as current user ?
vipankumar87 liked this reply
@suhailparad right I tried this solution https://stackoverflow.com/questions/70986081/why-extra-query-running-in-eloquent
but it is not good executing many queries but i can do in single query but i want to do it in laravel way not in pure sql
You can write a relation in Interest::class to fetch all the users with same interest.
can you please help me out on this or can give me idea how i can do this, i searching and try to accomplish this but i am unable to do
Interest Table
create table interests ( id bigserial primary key, name varchar(255) default ''::character varying not null, post_count bigint default '0'::bigint, created_at timestamp(0), updated_at timestamp(0), deleted_at timestamp(0) );
User_interest Pivot Table
create table user_interest ( user_id bigint not null constraint user_interest_user_id_foreign references users on delete cascade, interest_id bigint not null constraint user_interest_interest_id_foreign references interests on delete cascade );
User Table
create table users ( id bigserial primary key, name varchar(255) not null, email varchar(255) not null constraint users_email_unique unique, email_verified_at timestamp(0), password varchar(255) not null, remember_token varchar(100), created_at timestamp(0), updated_at timestamp(0), username varchar(255) not null constraint users_username_unique unique, profile_status varchar(255) default '0'::character varying );
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community