Join or group two models together that share a polymorphic relation?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I've built a reports system where users can report posts or comments to be moderated that have violated the rules of the site.
I would like to query both the comment and post reports together and group the reports together under the comment or post they belong to. Then I want organize by the post or comments created_at
fields.
Tables
Posts
- id (int)
- content ( text)
- title (text)
- created_at
Comment
- id (int)
- content (int)
- post_id (int)
- created_at
Report
- id (int)
- user_id (int)
- content (text)
- reportable_id (int)
- reportable_type (string)
User
- id (int)
- name (string)
Relations
Post.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Comment.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Report.php
public function reportable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
What I would like to do
I want to organize reports in 3 separate ways.
1. Get all posts with reports and the users that made the report and organize by latest.
$posts = Post::whereHas('reports')->with('reports.user', 'comments')->latest()->get();
Output:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
2. Get all comments with reports, the users that made the report, the post the comment is under and organize by latest.
$comments = Comment::whereHas('reports')->with('reports.user', 'post')->latest()->get();
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
3. Here is where I'm having trouble. I would like to organize Post
and Comment
Reports together and maintain grouping the reports under the model like above. Example:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
Here is my attempt at trying to get both Post
and Comment
reports together:
$reports = Report::with('reportable')->latest()->get();
//return view('reports.index', compact('posts'));
Output
"7": [
{
"id": 9,
"user_id": 2,
"content": "Guy is being a jerk",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:25",
"updated_at": "2017-08-22 01:31:25",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 8,
"user_id": 2,
"content": "this guy is being rude",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:02",
"updated_at": "2017-08-22 01:31:02",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 6,
"user_id": 1,
"content": "Report number 1",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-21 20:40:55",
"updated_at": "2017-08-21 20:40:55",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22"
}
}
],
"9": [
{
"id": 10,
"user_id": 4,
"content": "Rule 1",
"reportable_id": 9,
"reportable_type": "App\Post",
"created_at": "2017-09-20 21:31:50",
"updated_at": "2017-09-20 21:31:50",
"is_handled": 0,
"reportable": {
"id": 9,
"author_id": 1,
"title": "Hello world!",
"created_at": "2017-09-10 16:49:07",
"updated_at": "2017-09-10 16:49:07",
}
}
],
"24": [
{
"id": 11,
"user_id": 4,
"content": "Rule 2",
"reportable_id": 24,
"reportable_type": "App\Comment",
"created_at": "2017-09-20 22:28:15",
"updated_at": "2017-09-21 03:03:28",
"is_handled": 1,
"reportable": {
"id": 24,
"user_id": 1,
"content": "<p>A comment to be edited</p>",
"created_at": "2017-09-17 22:41:35",
"updated_at": "2017-09-17 22:41:35",
"commentable_id": 9,
"commentable_type": "App\Forum"
}
}
]
The problems I'm having is formatting the report right, pagination, and organizing the reports by the Comment
and Post
created_at
date. Is there a way just to just query the Post
, Comments
, User
, and Reports
Model all together to achieve what I'm trying to do?
I'm really sorry for such a long post.
laravel eloquent
add a comment |
I've built a reports system where users can report posts or comments to be moderated that have violated the rules of the site.
I would like to query both the comment and post reports together and group the reports together under the comment or post they belong to. Then I want organize by the post or comments created_at
fields.
Tables
Posts
- id (int)
- content ( text)
- title (text)
- created_at
Comment
- id (int)
- content (int)
- post_id (int)
- created_at
Report
- id (int)
- user_id (int)
- content (text)
- reportable_id (int)
- reportable_type (string)
User
- id (int)
- name (string)
Relations
Post.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Comment.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Report.php
public function reportable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
What I would like to do
I want to organize reports in 3 separate ways.
1. Get all posts with reports and the users that made the report and organize by latest.
$posts = Post::whereHas('reports')->with('reports.user', 'comments')->latest()->get();
Output:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
2. Get all comments with reports, the users that made the report, the post the comment is under and organize by latest.
$comments = Comment::whereHas('reports')->with('reports.user', 'post')->latest()->get();
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
3. Here is where I'm having trouble. I would like to organize Post
and Comment
Reports together and maintain grouping the reports under the model like above. Example:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
Here is my attempt at trying to get both Post
and Comment
reports together:
$reports = Report::with('reportable')->latest()->get();
//return view('reports.index', compact('posts'));
Output
"7": [
{
"id": 9,
"user_id": 2,
"content": "Guy is being a jerk",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:25",
"updated_at": "2017-08-22 01:31:25",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 8,
"user_id": 2,
"content": "this guy is being rude",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:02",
"updated_at": "2017-08-22 01:31:02",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 6,
"user_id": 1,
"content": "Report number 1",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-21 20:40:55",
"updated_at": "2017-08-21 20:40:55",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22"
}
}
],
"9": [
{
"id": 10,
"user_id": 4,
"content": "Rule 1",
"reportable_id": 9,
"reportable_type": "App\Post",
"created_at": "2017-09-20 21:31:50",
"updated_at": "2017-09-20 21:31:50",
"is_handled": 0,
"reportable": {
"id": 9,
"author_id": 1,
"title": "Hello world!",
"created_at": "2017-09-10 16:49:07",
"updated_at": "2017-09-10 16:49:07",
}
}
],
"24": [
{
"id": 11,
"user_id": 4,
"content": "Rule 2",
"reportable_id": 24,
"reportable_type": "App\Comment",
"created_at": "2017-09-20 22:28:15",
"updated_at": "2017-09-21 03:03:28",
"is_handled": 1,
"reportable": {
"id": 24,
"user_id": 1,
"content": "<p>A comment to be edited</p>",
"created_at": "2017-09-17 22:41:35",
"updated_at": "2017-09-17 22:41:35",
"commentable_id": 9,
"commentable_type": "App\Forum"
}
}
]
The problems I'm having is formatting the report right, pagination, and organizing the reports by the Comment
and Post
created_at
date. Is there a way just to just query the Post
, Comments
, User
, and Reports
Model all together to achieve what I'm trying to do?
I'm really sorry for such a long post.
laravel eloquent
add a comment |
I've built a reports system where users can report posts or comments to be moderated that have violated the rules of the site.
I would like to query both the comment and post reports together and group the reports together under the comment or post they belong to. Then I want organize by the post or comments created_at
fields.
Tables
Posts
- id (int)
- content ( text)
- title (text)
- created_at
Comment
- id (int)
- content (int)
- post_id (int)
- created_at
Report
- id (int)
- user_id (int)
- content (text)
- reportable_id (int)
- reportable_type (string)
User
- id (int)
- name (string)
Relations
Post.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Comment.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Report.php
public function reportable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
What I would like to do
I want to organize reports in 3 separate ways.
1. Get all posts with reports and the users that made the report and organize by latest.
$posts = Post::whereHas('reports')->with('reports.user', 'comments')->latest()->get();
Output:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
2. Get all comments with reports, the users that made the report, the post the comment is under and organize by latest.
$comments = Comment::whereHas('reports')->with('reports.user', 'post')->latest()->get();
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
3. Here is where I'm having trouble. I would like to organize Post
and Comment
Reports together and maintain grouping the reports under the model like above. Example:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
Here is my attempt at trying to get both Post
and Comment
reports together:
$reports = Report::with('reportable')->latest()->get();
//return view('reports.index', compact('posts'));
Output
"7": [
{
"id": 9,
"user_id": 2,
"content": "Guy is being a jerk",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:25",
"updated_at": "2017-08-22 01:31:25",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 8,
"user_id": 2,
"content": "this guy is being rude",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:02",
"updated_at": "2017-08-22 01:31:02",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 6,
"user_id": 1,
"content": "Report number 1",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-21 20:40:55",
"updated_at": "2017-08-21 20:40:55",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22"
}
}
],
"9": [
{
"id": 10,
"user_id": 4,
"content": "Rule 1",
"reportable_id": 9,
"reportable_type": "App\Post",
"created_at": "2017-09-20 21:31:50",
"updated_at": "2017-09-20 21:31:50",
"is_handled": 0,
"reportable": {
"id": 9,
"author_id": 1,
"title": "Hello world!",
"created_at": "2017-09-10 16:49:07",
"updated_at": "2017-09-10 16:49:07",
}
}
],
"24": [
{
"id": 11,
"user_id": 4,
"content": "Rule 2",
"reportable_id": 24,
"reportable_type": "App\Comment",
"created_at": "2017-09-20 22:28:15",
"updated_at": "2017-09-21 03:03:28",
"is_handled": 1,
"reportable": {
"id": 24,
"user_id": 1,
"content": "<p>A comment to be edited</p>",
"created_at": "2017-09-17 22:41:35",
"updated_at": "2017-09-17 22:41:35",
"commentable_id": 9,
"commentable_type": "App\Forum"
}
}
]
The problems I'm having is formatting the report right, pagination, and organizing the reports by the Comment
and Post
created_at
date. Is there a way just to just query the Post
, Comments
, User
, and Reports
Model all together to achieve what I'm trying to do?
I'm really sorry for such a long post.
laravel eloquent
I've built a reports system where users can report posts or comments to be moderated that have violated the rules of the site.
I would like to query both the comment and post reports together and group the reports together under the comment or post they belong to. Then I want organize by the post or comments created_at
fields.
Tables
Posts
- id (int)
- content ( text)
- title (text)
- created_at
Comment
- id (int)
- content (int)
- post_id (int)
- created_at
Report
- id (int)
- user_id (int)
- content (text)
- reportable_id (int)
- reportable_type (string)
User
- id (int)
- name (string)
Relations
Post.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Comment.php
public function reports()
{
return $this->morphMany('AppReport', 'reportable');
}
Report.php
public function reportable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
What I would like to do
I want to organize reports in 3 separate ways.
1. Get all posts with reports and the users that made the report and organize by latest.
$posts = Post::whereHas('reports')->with('reports.user', 'comments')->latest()->get();
Output:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
2. Get all comments with reports, the users that made the report, the post the comment is under and organize by latest.
$comments = Comment::whereHas('reports')->with('reports.user', 'post')->latest()->get();
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
3. Here is where I'm having trouble. I would like to organize Post
and Comment
Reports together and maintain grouping the reports under the model like above. Example:
This is a post from 1 day ago
- Report 1 about comment by user 1
- Report 2 about comment by user 4
This is a post from 1 day ago
A nasty comment on a post by user 10
- Report 1 by user 1
- Report 2 by user 4
This is a post from 3 days ago
- Report 1 by user 3
- Report 2 by user 5
This is a post from 3 days ago
Another nasty comment on a post by user 15
- Report 1 by user 3
- Report 2 by user 5
Here is my attempt at trying to get both Post
and Comment
reports together:
$reports = Report::with('reportable')->latest()->get();
//return view('reports.index', compact('posts'));
Output
"7": [
{
"id": 9,
"user_id": 2,
"content": "Guy is being a jerk",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:25",
"updated_at": "2017-08-22 01:31:25",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 8,
"user_id": 2,
"content": "this guy is being rude",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-22 01:31:02",
"updated_at": "2017-08-22 01:31:02",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"category_id": null,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22",
}
},
{
"id": 6,
"user_id": 1,
"content": "Report number 1",
"reportable_id": 7,
"reportable_type": "App\Post",
"created_at": "2017-08-21 20:40:55",
"updated_at": "2017-08-21 20:40:55",
"is_handled": 0,
"reportable": {
"id": 7,
"author_id": 1,
"title": "A forum post!",
"created_at": "2017-08-08 23:03:22",
"updated_at": "2017-08-08 23:03:22"
}
}
],
"9": [
{
"id": 10,
"user_id": 4,
"content": "Rule 1",
"reportable_id": 9,
"reportable_type": "App\Post",
"created_at": "2017-09-20 21:31:50",
"updated_at": "2017-09-20 21:31:50",
"is_handled": 0,
"reportable": {
"id": 9,
"author_id": 1,
"title": "Hello world!",
"created_at": "2017-09-10 16:49:07",
"updated_at": "2017-09-10 16:49:07",
}
}
],
"24": [
{
"id": 11,
"user_id": 4,
"content": "Rule 2",
"reportable_id": 24,
"reportable_type": "App\Comment",
"created_at": "2017-09-20 22:28:15",
"updated_at": "2017-09-21 03:03:28",
"is_handled": 1,
"reportable": {
"id": 24,
"user_id": 1,
"content": "<p>A comment to be edited</p>",
"created_at": "2017-09-17 22:41:35",
"updated_at": "2017-09-17 22:41:35",
"commentable_id": 9,
"commentable_type": "App\Forum"
}
}
]
The problems I'm having is formatting the report right, pagination, and organizing the reports by the Comment
and Post
created_at
date. Is there a way just to just query the Post
, Comments
, User
, and Reports
Model all together to achieve what I'm trying to do?
I'm really sorry for such a long post.
laravel eloquent
laravel eloquent
edited Nov 27 '18 at 3:55
HCK
3,81011338
3,81011338
asked Nov 27 '18 at 1:57
user3325126user3325126
355316
355316
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Another way to format this would be to use instead of a morphMany()
is a hasMany()
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491681%2fjoin-or-group-two-models-together-that-share-a-polymorphic-relation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Another way to format this would be to use instead of a morphMany()
is a hasMany()
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
add a comment |
Another way to format this would be to use instead of a morphMany()
is a hasMany()
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
add a comment |
Another way to format this would be to use instead of a morphMany()
is a hasMany()
Another way to format this would be to use instead of a morphMany()
is a hasMany()
answered Nov 27 '18 at 4:14
Aiden KaiserAiden Kaiser
1076
1076
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
add a comment |
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
I'm not sure I follow as to why and what would the code look like for the query I'm trying to create?
– user3325126
Nov 27 '18 at 4:39
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
return $this->hasMany(‘AppReports’)
– Aiden Kaiser
Nov 27 '18 at 4:42
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
How would query both Comments and Posts Reports at the same time using many to many relationships?
– user3325126
Nov 27 '18 at 5:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491681%2fjoin-or-group-two-models-together-that-share-a-polymorphic-relation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown