#### Category : join

There’s a table in my SQL DB called "projects" and it has a column in it "categories" which is a varchar(255) representation of a php array "[‘category_1’, ‘category_2’, ‘category_3′]" and what i’d like to do is put these categories into a separate table which would be made of a unique integer id in addition to ..

$users = DB::table(‘users’) ->join(‘course’, ‘users.id’, ‘=’, ‘course.courseId’) ->join(‘skills’, ‘users.id’, ‘=’, ‘skills.id’) ->join(‘subjects’, ‘users.id’, ‘=’, ‘subjects.id’) ->get(); dd($users); This gives me an empty result like this- items: []. I would like to join the 4 tables – users, course, skills & subjects and fetch all the datas in all the 4 tables. users table has the ..

$u=$this->guard()->user(); $u holds the data of users table. With the id in$u, i want to join the location table & user_technical_details . How to do that? I’ve tried like below $users = join(‘location’, ‘users.id’, ‘=’, ‘location.id’) ->join(‘user_technical_details’, ‘users.id’, ‘=’, ‘user_technical_details.id’) ->get(); Sourc.. Read more I have StudentEducation model and in this model i got public function student_education_countries() { return$this->hasMany(StudentEducationCountry::class, ‘education_id’); } and public function student_education_education_types() { return $this->hasMany(StudentEducationEducationType::class, ‘education_id’); } in StudentEducationCountry model i got public function student_education() { return$this->belongsTo(StudentEducation::class, ‘education_id’); } public function student_country() { return $this->belongsTo(StudentCountry::class, ‘country_id’); } and in StudentEducationEducationType model i got public .. Read more i want to have all the records from district table even if there is no match in cases table in following query$object = DB::table(‘case_details as cd’) ->select( DB::RAW(‘SUM(cd.registered) AS registered’), "prv.$name AS province","crt.$name AS court", "dis.$name AS divan","c.court_id","c.divan_id" ); ->leftJoin(‘cases AS c’,’c.id’,’cd.case_id’) ->leftJoin(‘provinces as prv’,’prv.id’,’=’,’c.province_id’) ->leftJoin(‘courts as crt’,’crt.id’,’=’,’c.court_id’); ->rightJoin(‘districts as dis’,’dis.id’,’=’,’c.district_id’);$object = $object->groupBy("dis.id"); .. Read more this my Controller public function reporting() {$monthly_report = DB::table(‘monthly_report’) ->join(‘sita_invoice’,’sita_invoice.id_sita’,’=’,’monthly_report.id_sita’) ->join(‘traffic_log’,’traffic_log.id_aircom’,’=’,’monthly_report.id_aircom’) ->get(); return view(‘traffic.report’, compact(‘monthly_report’)); } but not getting any data from other tables Sourc..

To quickly summarize, my first table’s rows gets multiplied by the amount of rows in the second table possibly due to my join: Table 1:(bbr_group) I only have two rows 1 Table 2:(bbr_group_type) I only need to get group_type_name, joined by group_type_id 2 Controller: public function fetchgroup(){ $all_groups = HmsBbrGroup::join(‘hms_bbr_group_type’, ‘hms_bbr_group.group_type_id’, ‘=’, ‘hms_bbr_group.group_type_id’) ->orderBy(‘group_id’, ‘ASC’)->get(); .. Read more I have 3 tables i.e category, sub category and products. I have passed category id to sub category and then sub category id to product so that i can get the whole data as per requirements. The problem in i an able to get the data from the secondary tables that has joins statement not .. Read more Im trying to union 2 joins, but im getting weird error… I have "Clientes" -> means clients, and i got all the clients that they got registered in orders and news. In news table i got the cliente_id -> client_id , And in orders, i got the same, cliente_id -> client_id, In news i got .. Read more Actually i have 3 tables, clients, orders, and news, Ordrers and News also have a field named "Office_id" that reference to the id of the office ( we got like 15 offices here in the city) Orders and news, have a field named "client_id", that references to the client when a new or order is .. Read more I have 3 Models User , MyClass And AssignedClassModels Users Table id forename lastname 1 Rayhan Parvez 2 Tuhin Saud 3 Asif Ahmed 4 Shuvo Khan MyClasses table id name 1 Ten 2 Six AssignedClassModels Table id MyClass_id user_id 1 1 1 2 2 2 3 1 3 4 2 4 So, now I want .. Read more Is there a way to write this query in Eloquent? select * from (select distinct source_id from csv_report) CR JOIN source SRC on CR.source_id = SRC.id; I don’t have the Models relations set up yet. Thanks. EDIT: Sorry if I didn’t ask the question correctly (because of the negative point). I figured the table details .. Read more Using join function returns no results when running phpUnit with queries over multiple databases. It it database Connection issue? If i run the API on PostMan than I am getting the expected return but in PhpUnit Test I am getting an empty Array! Sourc.. Read more I need help with this query,$data_query->leftJoin(‘categories as parent_category’, ‘invoice.category_id’, ‘=’, ‘parent_category.id’) ->leftJoin(‘categories as child_category’, ‘parent_category.id’, ‘=’, ‘child_category.id’) ->whereRaw("concat(parent_category.name,’/’,child_category.name), ‘like’, ‘%".$filter."%’"); I am getting this error "Column not found: 1054 Unknown column ‘parent_category.name’ in ‘where clause’ at /home…" and I understand what it means, but don’t know why I am getting it. Any advice on .. Read more I want to make search function on join table (pjname table and pjtype table) search function can working if no display pjtype name but if I display pjtype name from pjtype table it has error enter image description here this is my code PjnameModel <?php namespace App; use IlluminateDatabaseEloquentModel; class PjnameModel extends Model { protected .. Read more im working on a join/find laravel DB to retrieve te correct data, but it is showing the last entry of the database repeated 13 times. I hope you can help me. Here is the code. in controller$joinCot = Cotizaciones::findOrFail($id);$joinCot = DB::table(‘cotizaciones’)->join(‘prod_cotizaciones’, ‘prod_cotizaciones.id_cotizacion’, ‘=’, ‘cotizaciones.id’) ->join(‘users’, ‘users.id’, ‘=’, ‘cotizaciones.id_usuario’) ->join(‘clientes’, ‘clientes.id’, ‘=’, ‘cotizaciones.id_cliente’) ->select(‘cotizaciones.id’, ..

i feel too difficult when trying to fix this. i want to update my existing data. heres my laravel code: public function updateakun() { $user = User::leftjoin(‘sosmeds’, ‘users.id’, ‘sosmeds.user_id’)->find(request(‘id’));$user->name = request(‘nama’); $user->email = request(’email’);$user->username = request(‘username’); $user->bio = request(‘bio’);$user->ig = request(‘ig’); $user->update(); return response()->json([ ‘success’ => true, ‘message’ =>$user, ]); } ..

I’m using a made up scenario, but facing similar issue. I’m using Laravel 8 and have two models Family & Centre. Both containing common column name id. In model Family I want to restrict families data based on centre of user logged in. For now I’m hardcoding it a dummy centre_id Below is my booted ..

How can I join three tables where the foreign ID of each table are part of another, In the below code, I am trying to get all payments from PaymentsTable which have invoice_id, and InvoiceTables which have customer_id, Now with each payment row, I want to get customer information as well, So I can get ..

I have some tables in my database and I’m trying to transact between them. My aim is to show the project name and the employees in that project in the form of cards on my projects page as in the image below. (Other than the method I mentioned, if there are better ways to do ..

my database tables One is Categories with (Id, name) 2nd is Blog with (id, post, img) 3rd is Blog_category with (id, blog_id, category_id) query I’m using $blogs = Blog::join(‘categories’, ‘blog_categories.category_id’, ‘=’, ‘categories.id’)->orderBy(‘created_at’, ‘DESC’)->get(); return response()->json($blogs, 200); error I’m getting SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘blog_categories.category_id’ in ‘on clause’ (SQL: select * from blogs ..
I just want to know that which join will be used behind the scenes in Laravel join(). Either it is leftjoin(), rightjoin() or innerjoin() ? For example: What join will be used here actually? $friends_votes = DB::table(‘users’) ->join(‘votes’, ‘votes.user_id’, ‘=’, ‘users.id’) ->where(‘votes.user_id’,1); Sourc.. Read more can some one help me to do in laravel join for 3 tables ( payments, invoice_payments & attendances) every table has (id, user_id, amount & date) i want to join 3 tables throw user_id and date by month as the date format dd-mm-yyyy to get the sum amount for every table and groupby month, user_id .. Read more I tried to put orderBy(hr_workers.l_name) before get() but it’s not working.. also tried to put it on$workers but still not working… I don’t have any idea why isn’t working… anyone can help me all answer must be appreciated thanks in advance I want the result is alphabetically arrange by last name public function show6(\$id) ..