laravelista / comments Goto Github PK
View Code? Open in Web Editor NEWNative comments for your Laravel application.
License: MIT License
Native comments for your Laravel application.
License: MIT License
Hello,
This package is awesome. I set it up in a few minutes, adjusted it to my liking and then tried to deploy a test version to my appengine production project.
As far as I can tell its happening during the composer scripts. As an example:
Step #1 - "builder": In Compiler.php line 36:
Step #1 - "builder":
Step #1 - "builder": Please provide a valid cache path.
... then ...
Step #1 - "builder": Generating optimized autoload files
Step #1 - "builder": > Illuminate\Foundation\ComposerScripts::postAutoloadDump
Step #1 - "builder": > @php artisan package:discover --ansi
Step #1 - "builder": Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Step #1 - "builder":
Step #1 - "builder": error: `composer_install` returned code: 1
Step #1 - "builder": Traceback (most recent call last):
Step #1 - "builder": File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
Step #1 - "builder": "__main__", fname, loader, pkg_name)
Step #1 - "builder": File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
Step #1 - "builder": exec code in run_globals
Step #1 - "builder": File "/usr/local/bin/ftl.par/__main__.py", line 65, in <module>
Step #1 - "builder": File "/usr/local/bin/ftl.par/__main__.py", line 57, in main
Step #1 - "builder": File "/usr/local/bin/ftl.par/__main__/ftl/common/ftl_error.py", line 58, in UserErrorHandler
Step #1 - "builder": IOError: [Errno 2] No such file or directory: '""/output'
Finished Step #1 - "builder"
ERROR
ERROR: build step 1 "gcr.io/gae-runtimes/php72_app_builder:php72_20190515_7_2_17_RC00" failed: exit status 1
Just wanted to know if you had any idea what could be causing this? I am using Laravel 5.7, php72 and if I composer remove
your package, the deployment scripts run fine. My suspicion is that it is trying to cache or discover something in your package (or the included markdown parser) and failing.
Keep in mind, I realize your package probably works on 99% of deployments... and appengine is a weird case. So I'm just looking for advice if you have time. The issue seems to happen at the same step as this previously closed ticket: #16
Thanks!
Hello.
I`m trying to install this package in PHP 7.3
composer install
But i have error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravelista/comments 2.0.1 requires php 7.2.* -> your PHP version (7.3.1) does not satisfy that requirement.
- laravelista/comments 2.0.1 requires php 7.2.* -> your PHP version (7.3.1) does not satisfy that requirement.
- Installation request for laravelista/comments 2.0.1 -> satisfiable by laravelista/comments[2.0.1].
How to fix it? thanks...
Please, add support PHP 7.3
I just want add more fields like a 'select' in comment form.
Can I do this by just modifying the db table and incrementing form with new fields?
How can i use laravelista/comments in order to show latest posted comments on top rather than first comment posted.
Hi! Honestly I did not understand one thing, Can it be used on multiple pages or just one?
How do you know which article is that comment?
Are you planning to keep rating feature as well ?
With only 38 comments with multiple nested comments page started loading in 1+ second.
The problem is in
Replacing
@if(array_key_exists($comment->id, $grouped_comments->toArray()))
with
@if($grouped_comments->has($comment->id))
fixes the issue. my page load time dropped to 200ms.
Hello. I'm brazilian and need to translate the component to portuguese-br. Is that possible? Thanks.
I just installed this package using composer. But when i continue to migrate the database, it showed that nothing to migrate. I'm using steps from this page.
But when i open readme.md in vendor file, it's different. File structure is different too.
Seems like when im running composer require, it downloads ver.1xx
Everything worked fine until the first comment. console produced an error with following trace
""""""""""""""""""""""""""""""""""
Uncaught Error: Illegal argument undefined
at e.exports (comments-react.js:12)
at t.value (comments-react.js:11)
at comments-react.js:13
at s (comments-react.js:12)
at _renderValidatedComponentWithoutOwnerOrContext (comments-react.js:13)
at _renderValidatedComponent (comments-react.js:13)
at _.performInitialMount (comments-react.js:12)
at _.mountComponent (comments-react.js:12)
at Object.mountComponent (comments-react.js:3)
at Object.updateChildren (comments-react.js:12)
""""""""""""""""""""""""""""""""""
Hi. It would be nice to have a boot method that listens to the delete event and remove any associated comments of the model.
I had the issue 'Please provide a valid cache path." when deploy.
I found a lot solution from web, and I had did below solution, but the error still occur
clear cache
php artisan route:clear
php artisan view:clear
php artisan config:clear
php artisan cache:clear
confirm file exist
storage/framework/cache
storage/framework/sessions
storage/framework/views
add code to bootstrap/app.php
$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
declare APP_STORAGE app.yaml
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp
SESSION_DRIVER: cookie
How can I override defined permission like edit-comment, delete-comment, etc.
I try to add them in my AuthServiceProvider, but it not work.
I have a timeline, where a user can comment on multiple statuses, but at the moment, this uses an ID, so will only render to 1, is it possible to change to a class so it renders to all on the page? I tried changing some of the code, but kept getting:
Target container is not a DOM element
I changed:
<div id="laravelista-comments"></div>
to
<div class="laravelista-comments"></div>
and in the app.js to:
import React from 'react';
import ReactDOM from 'react-dom';
import CommentBox from './components/CommentBox.jsx';
window.Laravelista = window.Laravelista || {content_type: null, content_id: null, login_path: '/login'};
var elementLength = document.getElementsByClassName("laravelista-comments").length;
if (elementLength > 0) {
for (var i = 0; i < elementLength; i++) {
ReactDOM.render(
<CommentBox content_type={Laravelista.content_type} content_id={Laravelista.content_id} login_path={Laravelista.login_path} />,
document.getElementsByClassName('laravelista-comments')[i] //mountNode
);
}
}
Is there anyway to achieve this?
I see some "how to install" on the main page, but is there no documentation beyond that? I am trying to make a rest api, so i need routes to create and such. Also, when I install, I don't have a migration file for comments. Any ideas as to what's going on?
Hello,
seems to be a great package. Unfortunatelly when I try to install it it shows me this:
- Installing laravelista/comments (2.0.1): Loading from cache
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
In Facade.php line 221:
Call to undefined method Illuminate\View\Compilers\BladeCompiler::component()
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
Any idea how to fix this ? I'm using Laravel 5.5.40
Hey !
Well done with this plugin. It's very useful.
I only got one thing to suggest : Add localization feature. I think it would be very appreciated and will make it even better.
Hi. I wanted to give your package a shot and implementation went smoothly until I tried to post a comment for the first time.
It appears that three api calls happen, two of which are the same:
one is a GET of /api/v1/comments, returns a 422. this is the response: {"error":{"message":{"content_type":["The content type field is required."],"content_id":["The content id field is required."]},"status_code":422}} It doesn't seem to send the contents of window.Laravelista, which I have to imagine is what it wants to do.
Then a second one happens that seems marginally more successful. It is a GET of http://www.airhub.dev/api/v1/comments?content_type=App%5CModels%5CExpense&content_id=19, which returns something like this: {"data":[],"meta":{"user":{"data":{"id":2,"name":"User Name","email":"[email protected]"}}}}
But the content I type in never seems to be posted.
I'm trying it out with Chrome 57, Laravel 5.2, and PHP 7.
If I had a non-minified copy of the React I would spend more time trying to suss out the issue, although my React skills are limited; since only the minified versions are in the repo, I'm just going to go ahead and ask for help.
Thanks!
Why require php 7.2.* when the latest version of Laravel uses 7.1.*?
I have 4 users in my users table, those are:
My issue is both [email protected] and [email protected] cannot save the comment while 2 others are working very well, any solution for this?
I would like users to be able to leave a comment as a guest (without logging in) on my project. Is there any support or roadmap for this? If not, would you be open to a PR? I would think requiring a recaptcha a for guest comments would be sensible.
Because I plan to enable guest commenting I think that there should be a system in place to control "review" comments before displaying them on website.
I used this package (a modified version) for handling product reviews and there you don't really want to display the reviews right away before checking them.
The UI for doing this should be up to the developer "you" to implement in your website, but the feature will be available in this package by setting the approval_required
configuration option to true
.
This option will make use of the approved
boolean column in the database for comments.
Then you could fetch only approved comments by using a scope approved()
in your controller or something like that.
How to Have a View i copy it but nothing happend
Call to undefined method xxxx\Presenters\PostsPresenter::findOrFail()
this happens when I tried to post.
After some analysis i dropped the (mccool) pagepresenter, because this causes it. I just uses the presenter for the date, which can easily be finetuned from blade itselves.
Although, if somebody knows how I can combine this package with a presenter (which has no findorfail method inside), I will be glad to hear.
Use ES6 and webpack
So cool if you add tailwindcss
Hi,
thanks for the package.
I believe I found an issue with the migration. The child_id
foreign key has a different column type from the id
column. So, when you run php artisan migrate
, an error occurs:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
More info:
foreign key (
child_id) references
comments (
id) on delete cascade: Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint. Note that the internal storage type of ENUM and SET changed in tables created with >= InnoDB-4.1.12, and such columns in old tables cannot be referenced by such columns in new tables. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-foreign-key-constraints.html for correct foreign key definition.
Changing the column type of the child_id column from BIGINT to INT fixes the issue:
$table->unsignedInteger('child_id')->nullable();
I tried to change some param in comments.php like guest_commenting=true, and then I run:
php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=config.
After that in the view page I print the guest_commenting by
{{dd(config('comments.approval_required'))}}
but I was show false. How can I fix that? Thank you very much for your help.
We're using the Laravel Guards system. Has anyone gotten this to work with this yet? We can't seem to get this one to work with this type of setup for commenters:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'member' => [
'driver' => 'session',
'provider' => 'member',
],
],
I've tried to use the following as well:
'controller' => '\XXXXXXXX\Member\Http\Controllers\Comments',
Which is:
<?php
namespace XXXXXXXXX\Member\Http\Controllers;
use Laravelista\Comments\CommentController;
class Comments extends CommentController
{
public function __construct()
{
$this->middleware('member');
if (config('comments.guest_commenting') == true) {
$this->middleware('auth')->except('store');
} else {
$this->middleware('auth');
}
}
}
It seems it's not seeing my change to the config pointing at the new controller after a dump-autoload as well. So, my question, does this package support the guard system and us defining 'provider' => 'member',
?
Because I'm not seeing it pick up the logged in member's session at all, where the member can view their dashboard and etc, but on this blog post, we're trying to get this to work there, and it still shows the login button and it's not seeing they're logged in...
Even when logged in my laravelista comments section still shows "You must login to post a comment". Please help me fix this. Laravel 5.4.0/PHP 5.6.29
The default image is showing with the comment.
I have image path of user profile in column name avatar in user table.
How can i set the image from that column
Hello,
First of all, thanks for this package, but right in the start the migration is failing, please see below, and yes, I have max set inside the AppServiceProvider.php as follows:
Schema::defaultStringLength(191);
php artisan migrate
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `comments` add index `comments_commenter_id_commenter_type_index`(`commenter_id`, `commenter_type`))
In PDOStatement.php line 143:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
In PDOStatement.php line 141:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
I reproduced all the steps provided in the installation, included the comments in my designated Model, being simple news articles, but I can't seem to comment anything even though a user is logged in, when I press on the login link (as a logged in user) in "You must login to post a comment." It redirects me to a /home route that doesn't exist in my project, otherwise, if a user isn't logged in, the link redirects me to my login page.
Any help would be appreciated!
Hello,
I just added laravelista/comments 3.1.0 to my project based on Laravel 6. But after a long moment of research, whatever the action of comment (add, delete, update), the route /comments redirects to /login .
I did not modify the config file (and also tested with "guest_commenting" to true and false).
My config Laravel is "basic".
The migration has been launched.
The "auth" middleware is working properly on the other controller / route.
In my App\Models\User I added:
use Laravelista\Comments\Commenter;
class User extends Authenticatable
{
use Notifiable, Commenter;
}
In my App\Models\Profile I added:
use Laravelista\Comments\Commentable;
class Profil extends Model
{
use Commentable;
}
In my Controller I have:
$comment = Profile::find($id);
In my view file.blade.php I added:
@comments ([
'model' => $ comment
])
An idea ?
Thank you in advance !
Trying to install the package i get :
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
ErrorException : Invalid argument supplied for foreach()
at C:\laragon\www\test\vendor\laravelista\comments\src\ServiceProvider.php:37
33| * Define permission defined in the config.
34| */
35| protected function definePermissions()
36| {
> 37| foreach(config('comments.permissions') as $permission => $policy) {
38| Gate::define($permission, $policy);
39| }
40| }
41|
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "C:\laragon\www\test\vendor\laravelista\comments\src\ServiceProvider.php", [])
C:\laragon\www\test\vendor\laravelista\comments\src\ServiceProvider.php:37
2 Laravelista\Comments\ServiceProvider::definePermissions()
C:\laragon\www\test\vendor\laravelista\comments\src\ServiceProvider.php:52
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
I'm using the latest Laravel. which is 6.5.1
updated from 6.4.1
Any idea whats wrong here?
How can I call the comment count for each post?
Hello,
thanks for the great package. If I enable guest commenting, the user cannot write comments anymore. The problem is that the controller is applying the guest commenting validation rules if the guest commenting is enabled and not, if the user is actually a guest.
If I change if (config('comments.guest_commenting') == true) {
into if (! Auth::check()) {
in the following code, it is working fine.
// Define guest rules if guest commenting is enabled.
if (config('comments.guest_commenting') == true) {
$guest_rules = [
'guest_name' => 'required|string|max:255',
'guest_email' => 'required|string|email|max:255',
];
}
I'm in PST but seeing the datetime for each comment in UTC.
Any suggestions on having the UX show the correct timezone?
Hi. Is there a out of the box way to optimize performance for more levels of replies? In your views there are on the fly queries being executed.
Would have been nice to have a library like https://github.com/lazychaser/laravel-nestedset used for this purpose.
Hey,
I wanna show the user if a comment was changed. I'd add a column 'edited' (datetime) and show the status ('last changed') in the views. Are you okay with a PR?
Is there an option for me to add a "flag comment" function to this component, or are there plans to add this functionality?
Hi.
https://github.com/laravelista/comments/blob/master/resources/views/_comment.blade.php#L1
I recommend use "Safe Mode".
https://github.com/erusev/parsedown#security
becouse now SafeMode disabled, and it have xss injection.
Maybe solution:
Change line number 2 in _comment.blade.php:
@php($markdown->setSafeMode(true))
Thanks...
Hello,
In a query listing commentable articles, is it possible to make an orberBy number of comments?
Thanks !
TODO:
#comments
I have just downloaded laravelista/comments.
I followed the instructions exactly, I think, when I open localhost:8000/post/show/1
(because that is my specified view),it shows the details of the post and the comment text area.When I type into the comment textarea, and press submit,it reloads the page and does NOTHING.It doesn't insert the data into the comment
table nor does it show the just typed comment nor does it even show any error.So at this point,I don't have a clue what is going wrong.
I know I am supposed to post some of my code,but I don't know which code to post,whether it is the routes
,the blades
files,the migrations
,the db schema
,the laravelista/comments
source etc and I can't just go ahead and post everything or post some code that you won't even need.
So please,any code that you may like to view to help me out just kindly let me know and I will be happy to show you.
Thanks in advanced
I follow all the step but it not working.
3)for this also Laravelista\Comments\Commenter same error
While the software was extremely easy to install and start using, it has several downfalls that I believe can be fixed by using blade for displaying.
For example, users may have different timezone settings and as it's currently not possible to apply those settings when displaying the times. Another thing that I would like to do is remove the icon that is displayed next to the posts but again.
When I log in and try to connect the page just reloads but the comment is not posted to the database.
I'm using wamp for my development in Laravel
Hello Laravelista,
I really appreciate your efforts for this package, i was just thinking if you can add the like feature on comments and replies. then this package would be more flexible and usable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.