Closed EricTalv closed 3 years ago
Here you need to pass the commentable model
comments(['model' => $book])
The user model should have the Commenter trait.
The Book model in this example, would need to have Commentable trait.
Check the config comments.php if you use custom location for models.
Well I added everything needed, my Article model has Commentable and User has Commenter.
The comments are coming to my database if I use $article->user
but are not getting displayed.
If I only pass the Commentable Model I get the strange error referenced in my last post.
I will need to verify this, but something looks funny in your previous issue. Can you reopen it?
I also do not show comments, although they are in the database. I call it like this: @comments(['model' => $post])
my Post.php it looks like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravelista\Comments\Commenter;
class Post extends Model
{
use Commenter;
protected $table = 'topcashback';
protected $fillable = ['id', 'name'];
}
the page call looks like this:
public function CashBackInfo(Post $post,Request $r, $service) {
$cashbacksite = DB::table('topcashback')->where('name', $service)->get();
$info = 1;
$post = $post->first();
return view('pages.top.CashBackInfo', compact('cashbacksite', 'info', 'post'));
}
The data is sent to the database:
But it doesn't output them
Is there even an option to avoid the model? For example, specifying the category and id of the record? For example @comments(['category' => 'shops', 'id' => "1"])
I also do not show comments, although they are in the database. I call it like this: @comments(['model' => $post])
my Post.php it looks like this:
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Laravelista\Comments\Commenter; class Post extends Model { use Commenter; protected $table = 'topcashback'; protected $fillable = ['id', 'name']; }
the page call looks like this:
public function CashBackInfo(Post $post,Request $r, $service) { $cashbacksite = DB::table('topcashback')->where('name', $service)->get(); $info = 1; $post = $post->first(); return view('pages.top.CashBackInfo', compact('cashbacksite', 'info', 'post')); }
The data is sent to the database:
But it doesn't output them
Is there even an option to avoid the model? For example, specifying the category and id of the record? For example @comments(['category' => 'shops', 'id' => "1"])
So i had this issue i found my problem was i not using "use Laravelista\Comments\Commentable;" i messed up and never noticed i added "use Laravelista\Comments\Commenter;" so maybe double check :)
So i had this issue i found my problem was i not using "use Laravelista\Comments\Commentable;" i messed up and never noticed i added "use Laravelista\Comments\Commenter;" so maybe double check :)
Heu. it really worked! Thanks!!!
used use Laravelista\Comments\Commentable; use Commentable; Instead of use Laravelista\Comments\Commenter; use Commentable;
It is solved now?
It is solved now?
I have, yes
I double checked the commentable and commenter fields but these are fine, I am still getting the error on #144 , I tried opening a re-production on a different laravel project but on there seems to work fine, so this is definitely unique to my project. Perhaps you can take a look at it here https://github.com/EricTalv/laravel-blog.
my stack trace goes here:
if (isset($approved) and $approved == true) {
$comments = $model->approvedComments;
} else {
-err-> $comments = $model->comments;
}
No idea what could be causing this :s
Uhh.
This should not be here: https://github.com/EricTalv/laravel-blog/blob/master/app/Article.php#L49-L52
This entire model is not needed: https://github.com/EricTalv/laravel-blog/blob/master/app/Comment.php#L21
Try deleting those two and see if it works.
Hello Again!
I am trying to include this package to my project and Initially I tried to do it by the book, that didn't work as it shows the error referenced in my last post here #144.
Now I thought I solved it by instead of giving my Commentable model I gave the user instead,
Now the commenting section is displayed and I can comment, when I submit a comment it comes to my database, but no comments are ever displayed, it's always showing the default "no comments yet" message.
What should I do?