PHP code example of baklysystems / laravel-commentable

1. Go to this page and download the library: Download baklysystems/laravel-commentable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baklysystems / laravel-commentable example snippets


'providers' => [

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Lanz\Commentable\CommentableServiceProvider',

],

 namespace App;

use Lanz\Commentable\Commentable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    use Commentable;

}

$post = Post::first();

$comment = new Lanz\Commentable\Comment;
$comment->body = 'My first comment!';
$comment->user_id = \Auth::id();

$post->comments()->save($comment);

dd(Post::first()->comments);
`
php artisan commentable:migration
`
php artisan migrate