relationship

Laravel eloquent sort by role name on relationship model

痞子三分冷 提交于 2020-07-16 09:57:41
问题 I'm stuck with a problem where I have to sort / order a collection of models by their relationship's data. I've got it setup like this: Models: User , Team , TeamUser , Role The TeamUser model is a pivot model / table (containing user_id and team_id . If it's worth mentioning I am also using spatie/laravel-permissions for the roles. How would I go forth when I want to sort the users in a team by their role.name ? I'm talking about the users() relation in the Team model (see further down for

SQLAlchemy ORM not working with composite foreign keys

杀马特。学长 韩版系。学妹 提交于 2020-07-16 06:41:08
问题 I'm trying to build an example with several related models, like the following. We have a model B with a 1:n relation with a model C; then we have a model A with a n:1 relation with B and a n:1 relation with C. (C has a 2-columns primary key) I tried this code: class C(db.Model): __tablename__ = 'C' key1 = Column(Integer, primary_key=True) key2 = Column(Integer, primary_key=True) attr1 = Column(Date) attr2 = Column(Boolean) related_b = Column(Integer, ForeignKey('B.spam')) class B(db.Model):

“relation already exists” after adding a Many2many field in odoo

為{幸葍}努か 提交于 2020-07-08 12:27:52
问题 I've defined the following two odoo ORM models: class Weekday(models.Model): _name = 'ludwik.offers.weekday' name = fields.Char() class Duration(models.Model): _name = 'ludwik.offers.duration' weekday = fields.Many2many('ludwik.offers.weekday') When I try to start odoo I get the following message: ProgrammingError: relation "ludwik_offers_duration_ludwik_offers_weekday_rel_ludwik_offers_" already exists Also, when I change the _name properties in models, the problem persists (of course the

“relation already exists” after adding a Many2many field in odoo

◇◆丶佛笑我妖孽 提交于 2020-07-08 12:27:08
问题 I've defined the following two odoo ORM models: class Weekday(models.Model): _name = 'ludwik.offers.weekday' name = fields.Char() class Duration(models.Model): _name = 'ludwik.offers.duration' weekday = fields.Many2many('ludwik.offers.weekday') When I try to start odoo I get the following message: ProgrammingError: relation "ludwik_offers_duration_ludwik_offers_weekday_rel_ludwik_offers_" already exists Also, when I change the _name properties in models, the problem persists (of course the

Laravel Count Multiple Selected Data Who Has Relationship

ぐ巨炮叔叔 提交于 2020-07-04 01:51:30
问题 I have a problem when access data who has relationship. Below this syntax is work properly: $student = \App\StudentRegistrars::find($id); foreach($student->father_registrars as $getFatherData) { $fatherID = $getFatherData->id; $specificFather = \App\FatherRegistrars::where('id', $fatherID); $specificFather->update(['status' => 'Pending']); //count qualified students who have father with id $fatherID $getSelectedStudent = \App\StudentRegistrars::where('status', 'Qualified')->whereHas('father

Explanation of ER model to functional dependencies solution

久未见 提交于 2020-06-27 06:36:09
问题 I am trying to understand solution on one exercise that translates ER model to functional dependencies. As you can see above, we only have relation names and nothing else besides that, and by solution, they somehow come up to conclusion that mother, daughter → father father, daughter → mother mother, son → father father, son → mother And that moreover we can infer additional f dependencies to represent real world more accurately: mother, son → father father, son → mother What I don't

SwiftUI Core Data does not refresh “one to many” relations properly and lists are not refreshed

霸气de小男生 提交于 2020-06-27 03:40:52
问题 I'm trying to figure out what I can possibly be doing wrong (or, of course, misunderstood about relationships, fetches and all). In a first search, when I read the question's title, I hoped this question could help me, but I was wrong: SwiftUI TabView with List not refreshing after objected deleted from / added to Core Data Anyway... In my app, when I touch a customer item, the detail view is shown properly with its data. If I change any attribute and go back to the first view, its updated

Laravel get data from relationship and show in view

有些话、适合烂在心里 提交于 2020-06-26 14:54:08
问题 simply this code is my get data solution, this models are relationships and my result is true but i can't get data from relationship and show that on view, for example; $data = UserAccountNumber::with(['currency_type'])->orderBy('id', 'DESC')->paginate(50); this code return below result: LengthAwarePaginator {#585 ▼ #total: 2 #lastPage: 1 #items: Collection {#601 ▼ #items: array:2 [▼ 0 => UserAccountNumber {#588 ▶} 1 => UserAccountNumber {#589 ▼ #table: "user_account_numbers" #guarded: array

Relationship's entity's data is <fault>

时光总嘲笑我的痴心妄想 提交于 2020-06-17 09:45:52
问题 I have asked reference question in this link.I got answer using NSMangedObjectID.Now I have used below function to get Component entity from its componentID.As in the API response of SyncSurveyWebReadings,I only get componentId,I need to fetch Component entity & set as relationship.Now time taking issue is not there.But may be relationship is not getting set.When I print the relationship object I got, Optional<Array<SurveyReadingWeb>> ▿ some : 1 element - 0 : <GazSurvey_Dev.SurveyReadingWeb: