Questions tagged [relationship]

Questions in this tag typically involve the association that a set of data has with other set(s) of data.

5577 questions
1
vote
0 answers

Would a Polymorphic Relationship be the way to go?

I am creating a Laravel application and have to decide how to set up the database. I have 4 user types: Admin, Coach, Player, Parent. I'm using the Laravel default Auth tool (because it gets the job done and I like it), and as you know, it creates a…
Hunter
  • 438
  • 1
  • 5
  • 16
1
vote
2 answers

How to add same array key with different whenLoaded relationship?

From here, I want to put data from relationship to my API resources. With one key and one relationship, it works. But, with two different key and two same relationship, it doesn't. My goal is : If x relationship is loaded, use this data as key…
Alfan Zain
  • 55
  • 7
1
vote
1 answer

how do i pass data value to another page via link in laravel?

i am trying to make a list of locations that you can rent. but to rent the place you need to fill in some information. to fill in this information you excess another page. how do i make it so laravel knows the page belongs to a certain location this…
1
vote
2 answers

Problem with saving ManyToMany field data in intermediary models

First of all, sorry for my English. I have this structure, idea is: Product can have many suppliers, and supplier himself have products class Supplier(Model): title = CharField() def add_product(self, **kwargs): s2p =…
Igor
  • 479
  • 5
  • 13
1
vote
2 answers

Eloquent hasManyThrough also get middle table information

I have same table structure as mentioned in laravel document for HasManyThrough relationship hasManyThrough countries id - integer name - string users id - integer country_id - integer name - string posts id - integer user_id -…
Ruchita Sheth
  • 840
  • 9
  • 27
1
vote
2 answers

One Way Relationship in Core Data

Every restaurant must have Latitude and Longitude. However, every LatitudeLongitude object must not have "a restaurant" So I have a one way relationship and generate a compiler warning. What's the catch? Should I use fetchRelationship instead? But…
user4951
  • 32,206
  • 53
  • 172
  • 282
1
vote
1 answer

How to get One Table data on the basis of ID from another table

I have created 3 tables relation (users, projects, products) one user has many projects and one project has many products (one to many) I need to show all the projects and contained products on user login I have done it using the following code but…
Engr Umair
  • 130
  • 10
1
vote
1 answer

Eloquent get data from pivot table

Having difficulty, even after reading the docs, to get the 'property name' from the related 'properties' table while querying for a product from the 'products' table with the pivot 'product_properties'. My Models: Models\Product::class,…
McRui
  • 1,879
  • 3
  • 20
  • 31
1
vote
1 answer

fetch data for all users in same group

My code works. But I'm not sure is it a best solution. I need option to display user players and / or players from a group user belong to. Thank you for you time. $user = $request->user(); $userGroups = $user->groups; $friendsPlayers = []; foreach…
Danbass07
  • 29
  • 5
1
vote
0 answers

Relation on entities - android

I am using from architect component and I need to set a lot of query on bellow values. How to create relation between bellow entities for query? in normal mode I can't access to nested objects. For example I need to @Query("SELECT * FROM Content…
1
vote
1 answer

Any way to do simple count of relations with different 'where' clauses?

I have this relation in User model public function bulletins() { return $this->hasMany('App\Bulletins','owner'); } in controller I getting count of bulletins: dump( User::where('id',Auth::id()) ->withCount('bulletins') …
rst630
  • 59
  • 2
  • 14
1
vote
1 answer

Relationship to "jump" through M2M relationships in SqlAlchemy (User -> Role -> Permission)

I am trying to model a very typical permission structure where a User model (the human user of my website) can be assigned to some Roles, and each of those Roles has some Permissions. It would be really helpful if I could get a relationship from…
Savir
  • 17,568
  • 15
  • 82
  • 136
1
vote
2 answers

CakePHP: Retrieving records based on field in related model

I'm trying to search based on a field in a related model. I can do so with the belongsTo model, but not the hasMany model. I'm sure this is something simple I'm overlooking but I can't see it. Could someone point me in the right direction (or even…
1
vote
1 answer

Limiting the result of nested relationship in Laravel

I have a nested relationship that I want to set a condition and a limit. $data = Accommodation::with('accommodationFacilities', 'city') ->take(10) ->with('accommodationRooms.roomPricingHistory') ->limit(2) ->where('is_deleted', 0) …
Farshad
  • 1,830
  • 6
  • 38
  • 70
1
vote
1 answer

Retrieve username from User table for each member in a Team

I'm facing some issues in establishing relationships amongst User, Clan, and Clan Member models. I have three models in which I have defined the relationship as... Clan model public function clanMembers() { return…
1 2 3
99
100