yes sir, i made two method in model and no error, it means we can do in the model. Example: public function getCompanyData() { return $this->hasOne('App\Models\Company','emp_id'); } public function getCompanyData1() { return $this->hasMany('App\Models\Company','emp_id'); }
I have a doubt .... please clarify foreign key connection manually using eloquent ... because column name may sometime be different than the eloquent naming convention which may result in unwanted outcomes..
by default this function only looks for the column name containing "_d", so if you have column names other than containing "_id", you can do it like this assuming you are writing this in Member Model $this->hasOne("App\Models\Company","CompanyColumnName","MemberColumnName");
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'companies.employees_id' in 'where clause' (SQL: select * from `companies` where `companies`.`employees_id` = 1 and `companies`.`employees_id` is not null limit 1)
i fash this type of error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'curdlaravel8.companies' doesn't exist (SQL: select * from `companies` where `companies`.`student_id` = 1 and `companies`.`student_id` is not null limit 1)SIR HOW TO SOLVE THIS ERROR PLEASE HELP
Please support me by subscribe, like and comment :) thank you
yes sir, i made two method in model and no error, it means we can do in the model.
Example: public function getCompanyData()
{
return $this->hasOne('App\Models\Company','emp_id');
}
public function getCompanyData1()
{
return $this->hasMany('App\Models\Company','emp_id');
}
I have a doubt .... please clarify foreign key connection manually using eloquent ... because column name may sometime be different than the eloquent naming convention which may result in unwanted outcomes..
thank you bhai. you save my time..
example of : multiple employee to one company you have given has
many to one relation not one to one relation
thank you for simple and precise explanation
Yes! we can made both one to one and one to many method in a model
Exactly we create multiple methods in a class and call the required one
and good teaching method
by default this function only looks for the column name containing "_d", so if you have column names other than containing "_id",
you can do it like this assuming you are writing this in Member Model
$this->hasOne("App\Models\Company","CompanyColumnName","MemberColumnName");
if u use hasMany() and you have more than one id's matching ,
than u can use both , but if instead of both. hasMany() will return same result.
Thanks for such useful video
Relation bna ke hum data insert kar sakte hai ???
yes you can do
Did You Define Table name in Company Model.
Yes sir
Amazing!!
yes we can make more funtion
,pls make video on multi tancy
bro kindly create one for muli user login from one form . please mene bht dakha ha mgr is say related video nhy mil rhy achye ..
Thank you ❤️
Hi, brow please create video for many to many and many to one
many to many relation video sir?
Users table update like photo and text field.
Hello sir instead of using relations we can't use joins
Ye eleqouent models k relations hain agr join use krne hain phr i guess humain query builder use karna parega
@@taymoorkhan6376 Right Relationship makes ur life easy....But you are frsher then must work in Joins
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'companies.employees_id' in 'where clause' (SQL: select * from `companies` where `companies`.`employees_id` = 1 and `companies`.`employees_id` is not null limit 1)
bhai mera chal nahi raha column not found bata raha he
i fash this type of error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'curdlaravel8.companies' doesn't exist (SQL: select * from `companies` where `companies`.`student_id` = 1 and `companies`.`student_id` is not null limit 1)SIR HOW TO SOLVE THIS ERROR PLEASE HELP
create a companies table
Same brother! I already created companies table also this error
Help me please