PHP code example of laravolt / mural

1. Go to this page and download the library: Download laravolt/mural 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/ */

    

laravolt / mural example snippets




namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Laravolt\Mural\CommentableTrait;
use Laravolt\Mural\Contracts\Commentable;

class Post extends Model implements Commentable
{
    use CommentableTrait;

	public function getCommentableTitleAttribute()
	{
		// TODO: Implement getCommentableTitleAttribute() method.
	}

	public function getCommentablePermalinkAttribute()
	{
		// TODO: Implement getCommentablePermalinkAttribute() method.
	}

}

// mendapatkan semua komentar
Post::find(1)->comments;

// melakukan paginasi komentar
Post::find(1)->comments()->paginate();

// atau aksi apapun, sama seperti relasi Eloquent biasa
Post::find(1)->comments()->orderBy('created_at', 'desc');



namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravolt\Mural\Contracts\Commentator;

class User extends Authenticatable implements Commentator
{
    ...

    public function getCommentatorNameAttribute()
    {
        // return atribut nama
    }

    public function getCommentatorAvatarAttribute()
    {
        // return atribut link avatar
    }

    public function getCommentatorPermalinkAttribute()
    {
        // return atribut link ke detail user
    }

    public function canModerateComment()
    {
        // return boolean
    }
}
 php


return [
    // semantic-ui or bootstrap
    'skin'                => 'semantic-ui',

    // comment per page
    'per_page'            => 5,

    // whether user enable to vote comment or not
    'vote'                => false,

    // default commentable class (deprecated)
    'default_commentable' => \App\Models\Post::class,

    // default model for user commentator
    'default_commentator' => config('auth.providers.users.model')

    'middleware'   => ['web']
];