How can i get value from 3 table Joined with FK in Blade view
up vote
0
down vote
favorite
table : projects
enter image description here
table : projects_departmentsenter image description here
table : departmentsenter image description here
This is Model Project
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
This is Model Project_department
public function projects()
{
return $this->belongsTo(Project::class);
}
public function departments()
{
return $this->belongsTo(Department::class);
}
This is Model Department
public function projects()
{
return $this->hasMany(Project::class);
}
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
this is my blade
project->departments->department_name
This is MY error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'projects_departments.project_id' in 'where clause' (SQL: select * from projects_departments
where projects_departments
.project_id
= 48 and projects_departments
.project_id
is not null)
mysql laravel-5
New contributor
add a comment |
up vote
0
down vote
favorite
table : projects
enter image description here
table : projects_departmentsenter image description here
table : departmentsenter image description here
This is Model Project
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
This is Model Project_department
public function projects()
{
return $this->belongsTo(Project::class);
}
public function departments()
{
return $this->belongsTo(Department::class);
}
This is Model Department
public function projects()
{
return $this->hasMany(Project::class);
}
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
this is my blade
project->departments->department_name
This is MY error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'projects_departments.project_id' in 'where clause' (SQL: select * from projects_departments
where projects_departments
.project_id
= 48 and projects_departments
.project_id
is not null)
mysql laravel-5
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
table : projects
enter image description here
table : projects_departmentsenter image description here
table : departmentsenter image description here
This is Model Project
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
This is Model Project_department
public function projects()
{
return $this->belongsTo(Project::class);
}
public function departments()
{
return $this->belongsTo(Department::class);
}
This is Model Department
public function projects()
{
return $this->hasMany(Project::class);
}
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
this is my blade
project->departments->department_name
This is MY error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'projects_departments.project_id' in 'where clause' (SQL: select * from projects_departments
where projects_departments
.project_id
= 48 and projects_departments
.project_id
is not null)
mysql laravel-5
New contributor
table : projects
enter image description here
table : projects_departmentsenter image description here
table : departmentsenter image description here
This is Model Project
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
This is Model Project_department
public function projects()
{
return $this->belongsTo(Project::class);
}
public function departments()
{
return $this->belongsTo(Department::class);
}
This is Model Department
public function projects()
{
return $this->hasMany(Project::class);
}
public function projects_departments() {
return $this->hasMany(Project_department::class);
}
this is my blade
project->departments->department_name
This is MY error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'projects_departments.project_id' in 'where clause' (SQL: select * from projects_departments
where projects_departments
.project_id
= 48 and projects_departments
.project_id
is not null)
mysql laravel-5
mysql laravel-5
New contributor
New contributor
New contributor
asked Nov 7 at 7:52
Wisarut Chuwet
32
32
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
$project = DB::table('projects')
->select(*)
->join('Department', 'projects_departments.department_id', '=', 'Department.id')
->join('projects_departments', 'projects_departments.project_id', '=', 'projects.id')
->get();
let's try this one
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
$project = DB::table('projects')
->select(*)
->join('Department', 'projects_departments.department_id', '=', 'Department.id')
->join('projects_departments', 'projects_departments.project_id', '=', 'projects.id')
->get();
let's try this one
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
add a comment |
up vote
1
down vote
accepted
$project = DB::table('projects')
->select(*)
->join('Department', 'projects_departments.department_id', '=', 'Department.id')
->join('projects_departments', 'projects_departments.project_id', '=', 'projects.id')
->get();
let's try this one
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
$project = DB::table('projects')
->select(*)
->join('Department', 'projects_departments.department_id', '=', 'Department.id')
->join('projects_departments', 'projects_departments.project_id', '=', 'projects.id')
->get();
let's try this one
$project = DB::table('projects')
->select(*)
->join('Department', 'projects_departments.department_id', '=', 'Department.id')
->join('projects_departments', 'projects_departments.project_id', '=', 'projects.id')
->get();
let's try this one
answered Nov 7 at 8:55
kobi
8110
8110
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
add a comment |
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
Thank You. can I solved the problem.
– Wisarut Chuwet
Nov 7 at 9:38
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
@WisarutChuwet Did u get the answer? Then marked it as a answer
– kobi
Nov 7 at 10:57
add a comment |
Wisarut Chuwet is a new contributor. Be nice, and check out our Code of Conduct.
Wisarut Chuwet is a new contributor. Be nice, and check out our Code of Conduct.
Wisarut Chuwet is a new contributor. Be nice, and check out our Code of Conduct.
Wisarut Chuwet is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185383%2fhow-can-i-get-value-from-3-table-joined-with-fk-in-blade-view%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password