• Stars
    star
    900
  • Rank 48,878 (Top 1.0 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chatter is a Simple Laravel Forum Package

Build Status Build Status Total Downloads Latest Stable Version License

Laravel Forum Package - Chatter

Installation

Quick Note: If this is a new project, make sure to install the default user authentication provided with Laravel. php artisan make:auth

  1. Include the package in your project

    composer require "devdojo/chatter=0.2.*"
    
  2. Add the service provider to your config/app.php providers array:

    If you're installing on Laravel 5.5+ skip this step

    DevDojo\Chatter\ChatterServiceProvider::class,
    
  3. Publish the Vendor Assets files by running:

    php artisan vendor:publish --provider="DevDojo\Chatter\ChatterServiceProvider"
    
  4. Now that we have published a few new files to our application we need to reload them with the following command:

    composer dump-autoload
    
  5. Run Your migrations:

    php artisan migrate
    

    Quick tip: Make sure that you've created a database and added your database credentials in your .env file.

  6. Lastly, run the seed files to seed your database with a little data:

    php artisan db:seed --class=ChatterTableSeeder
    
  7. Inside of your master.blade.php file include a header and footer yield. Inside the head of your master or app.blade.php add the following:

    @yield('css')
    

    Then, right above the </body> tag of your master file add the following:

    @yield('js')
    

Now, visit your site.com/forums and you should see your new forum in front of you!

Upgrading

Make sure that your composer.json file is requiring the latest version of chatter:

"devdojo/chatter": "0.2.*"

Then you'll run:

composer update

Next, you may want to re-publish the chatter assets, chatter config, and the chatter migrations by running the following:

php artisan vendor:publish --tag=chatter_assets --force
php artisan vendor:publish --tag=chatter_config --force
php artisan vendor:publish --tag=chatter_migrations --force

Next to make sure you have the latest database schema run:

php artisan migrate

And you'll be up-to-date with the latest version :)

Markdown editor

If you are going to make use of the markdown editor instead of tinymce you will need to change that in your config/chatter.php:

'editor' => 'simplemde',

In order to properly display the posts you will need to include the graham-campbell/markdown library for Laravel:

composer require graham-campbell/markdown

Trumbowyg editor

If you are going to use Trumbowyg as your editor of choice you will need to change that in your config/chatter.php:

'editor' => 'trumbowyg',

Trumbowyg requires jQuery >= 1.8 to be included.

VIDEOS

Introduction and Installation of Chatter

Configuration

When you published the vendor assets you added a new file inside of your config folder which is called config/chatter.php. This file contains a bunch of configuration you can use to configure your forums

Customization

CUSTOM CSS

If you want to add additional style changes you can simply add another stylesheet at the end of your @yield('css') statement in the head of your master file. In order to only load this file when a user is accessing your forums you can include your stylesheet in the following if statement:

@if(Request::is( Config::get('chatter.routes.home') ) || Request::is( Config::get('chatter.routes.home') . '/*' ))
    <!-- LINK TO YOUR CUSTOM STYLESHEET -->
    <link rel="stylesheet" href="/assets/css/forums.css" />
@endif

SEO FRIENDLY PAGE TITLES

Since the forum uses your master layout file, you will need to include the necessary code in order to display an SEO friendly title for your page. The following code will need to be added to the <head> of your master file:

@if( Request::is( Config::get('chatter.routes.home')) )
    <title>Title for your forum homepage -  Website Name</title>
@elseif( Request::is( Config::get('chatter.routes.home') . '/' . Config::get('chatter.routes.category') . '/*' ) && isset( $discussion ) )
    <title>{{ $discussion->category->name }} - Website Name</title>
@elseif( Request::is( Config::get('chatter.routes.home') . '/*' ) && isset($discussion->title))
    <title>{{ $discussion->title }} - Website Name</title>
@endif

OVERRIDING VIEWS

In order to override Chatter's built in views, simply create a chatter folder in your vendor views folder, i.e. ROOT/resources/views/vendor/chatter. Then simply drop in the Chatter view files you would like to override.

Custom Function Hooks for the forum

Sometimes you may want to add some additional functionality when a user creates a new discussion or adds a new response. Well, there are a few built in functions that you can create in your script to access this functionality:

Before User Adds New Discussion Create a new global function in your script called:

function chatter_before_new_discussion($request, $validator){}

Note: that the $request object is passed with the user input for each webhook. You can use it if you would like :) If not, no worries just add your custom functionality.

After User Adds New Discussion Create a new global function in your script called:

function chatter_after_new_discussion($request){}

Before User Adds New Response Create a new global function in your script called:

function chatter_before_new_response($request, $validator){}

After User Adds New Response Create a new global function in your script called:

function chatter_after_new_response($request){}

Laravel Events for the forum

This package provides a number of events allowing you to respond to user actions as they happen:

Event Available properties Description
ChatterBeforeNewDiscussion Illuminate\Http\Request ($request), Illuminate\Validation\Validator ($validator) This event is fired before a discussion is validated and created
ChatterAfterNewDiscussion Illuminate\Http\Request ($request), Models::discussion() ($discussion), Models::post() ($post) This event is fired after a discussion has been validated and created
ChatterBeforeNewResponse Illuminate\Http\Request ($request), Illuminate\Validation\Validator ($validator) This event is fired before a response is validated and created
ChatterAfterNewResponse Illuminate\Http\Request ($request), Models::post() ($post) This event is fired after a response is validated and created

Listening for Events

To register your listeners for these events, follow the Laravel documentation for registering events and listeners. For example, to register a listener for the "before new discussion" event, add the following to your EventServiceProvider:

protected $listen = [
    'DevDojo\Chatter\Events\ChatterBeforeNewDiscussion' => [
        'App\Listeners\HandleNewDiscussion',
    ],
];

where App\Listeners\HandleNewDiscussion is a class in your application which handles the event when it's fired.

You can access the object that triggered the event in your listener with

    public function handle(ChatterAfterNewDiscussion $event)
    {
        // $event->discussion
        // $event->post
    }

and

    public function handle(ChatterAfterNewResponse $event)
    {
        // $event->post
    }

Screenshots

More Repositories

1

voyager

Voyager - The Missing Laravel Admin
PHP
11,658
star
2

wave

Wave - The Software as a Service Starter Kit, designed to help you build the SAAS of your dreams 🚀 💰
PHP
4,882
star
3

pines

The Pines UI library
HTML
2,007
star
4

genesis

An Application Starter Kit - Built with Laravel Folio and Volt
Blade
770
star
5

tails-components

The Tails Open Source Components are a (no-config) copy'n paste free collection of hand-crafted templates and components built in TailwindCSS.
HTML
701
star
6

larasail

LaraSail - Set Sail with your Laravel app on DigitalOcean
Shell
552
star
7

static

⚡️ The ultimate static site generator. Tailor-made for killer blogs, sizzling SaaS landings, audacious personal sites, and every web fantasy you dare to dream up.
JavaScript
128
star
8

php-login-script

This is a simple PHP login script using PHP, PDO, and MySQL
PHP
97
star
9

tailwind-breakpoint-tool

A simple breakpoint tool for develping your TailwindCSS sites.
JavaScript
91
star
10

voyager-themes

Theme Hook for Voyager
PHP
82
star
11

create-alpine-app

A simple starter template for your Alpine and Tailwind projects
HTML
56
star
12

voyager-polls

Create Interactive Polls with this hook for Voyager
Vue
47
star
13

laravel-user-image

Repo for episode tutorial on adding a user profile photo -
PHP
43
star
14

tails

This is the Tails composer package for Laravel. Easily fetch designs in your Laravel application that you design inside of the Tails Site/Page Builder.
PHP
35
star
15

create-a-php-routing-system

This repo is the code used in the DevDojo Creating a PHP Routing System Video Series
PHP
33
star
16

voyager-redirects

A Hook that allows you to add redirects to your Laravel and Voyager App
PHP
32
star
17

laravel-reactions

A Laravel Reactions Package
PHP
31
star
18

voyager-site

This is the source for LaravelVoyager.com website
HTML
26
star
19

voyager-installer

This is the repo for the Voyager installer
PHP
25
star
20

wordpress-import

This is a hook for Voyager that will import a Wordpress xml file into the Voyager DB
PHP
24
star
21

image-uploads-with-laravel-and-filepond

This is the source code for the video 'Image Uploads with Laravel and Filepond'
PHP
18
star
22

website-screenshot-with-laravel

Learn how to create a screenshot of a website with Laravel
PHP
16
star
23

themes

A package to add themes functionality in your Laravel application (Currently for Voyager)
PHP
14
star
24

livewire-trix-editor-post

This is a repository for the trix editor post written on the DevDojo
PHP
13
star
25

htmlinclude

A simple script allowing you to include html files inside of html
JavaScript
13
star
26

google-image-search

Google Image Search PHP Package
PHP
12
star
27

wordsmith-ui

The UI for the Wordsmith CMS built using the Tallstack
HTML
7
star
28

html5-platform-game

An HTML5 Platform Game created for https://devdojo.com/course/html5-platform-game
JavaScript
7
star
29

pages

This is one of the default themes for the Voyager Themes Hook
JavaScript
6
star
30

dribbble

Dribbble API Package for Laravel
PHP
5
star
31

behance

Behance API Package for Laravel 4
PHP
5
star
32

sample-theme

This is a very basic sample theme for Voyager Themes Hook
HTML
5
star
33

blog

The DevDojo Blog Power-up
Blade
4
star
34

laravel-socialite-tutorial

Laravel Socialite Tutorial
PHP
4
star
35

laravel-wave-api-endpoints

Endpoints for Wave API
4
star
36

welcome

A simple welcome package
PHP
4
star
37

mochi

Mochi Mini Framework
PHP
3
star
38

devblog

Developer Blogging Platform
JavaScript
3
star
39

forrst

A Forrst API Wrapper Package for Laravel 4
PHP
3
star
40

ninjamediascript

Ninja Media Script Documentation
JavaScript
3
star
41

create-a-php-singleton-class

This is the source code creating in the video 'The PHP Singleton Class'
PHP
3
star
42

blockjs

The BlockJS Editor
JavaScript
2
star
43

static-starter

The starter template for Static
HTML
2
star
44

devcoin

This is the repo for stored assets for the DevCoin
2
star
45

slider

A TailwindCSS Slider with multiple flavors including React, Vue, Alpine, and VanillaJS
JavaScript
2
star
46

blockjs-website

Website for BlockJS
CSS
2
star
47

app

This is the repo for the DevDojo products application package
PHP
2
star
48

.github

The Dev Community where we can all create, learn, and grow together.
1
star
49

laravel-deployer-cloudways

This is the repo for the Laravel Deployer Cloudways video
PHP
1
star
50

components

Components for your Laravel applications powered by Volt
Blade
1
star
51

devdojo

The DevDojo NPM CLI
1
star
52

Ninja-Media-Script-Theme-Default

Ninja Media Script Theme - Default
PHP
1
star
53

static.devdojo.com

The repo for the main static website
HTML
1
star