kaankilic/wtfilter

What The Filter is Profinaity Filter for Laravel

2.0.3 2018-07-25 21:19 UTC

This package is auto-updated.

Last update: 2024-12-12 23:55:59 UTC


README

WTFilter

Build Status Total Downloads Latest Stable Version License

Introduction

WTFilter provides an expressive and fluent way to filter profanities from the content with using it's own engine. WTFilter is the simplest stable profanity filter for Laravel.

License

Laravel WTFilter is open-sourced software licensed under the MIT

Official Documentation

It's simplest way of filtering profanities with the capabilities of Language form. You can set multilangual profanities on each language that you are using on your Laravel project.

Installation

To get started with WTFilter, use Composer to add the package to your project's dependencies:

composer require kaankilic/wtfilter

After installing the WTFilter library, register the Kaankilic\WTFilter\Providers\WTFilterServiceProvider in your config/app.php configuration file:

Kaankilic\WTFilter\Providers\WTFilterServiceProvider::class,

Also, add the WTFilter facade to the aliases array in your app configuration file:

'WTFilter' => Kaankilic\WTFilter\Facades\WTFilter::class

Lastly, Publish the config and language files.

php artisan vendor:publish --provider="Kaankilic\WTFilter\Providers\WTFilterServiceProvider"

This command will generate the configrations on your /config folder, and generate the default language folder on your project.

Basic Usage

<?php

namespace App\Http\Controllers;

use WTFilter;

class CommentsController extends Controller
{
    /**
     * It's filtering your comments that contains profanities.
     */
    public function createComment(Request $request){
    	$contentOfComments = WTFilter::filter($request->get("content_of_comment"));
        
    }
}

Model Trait Usage

You can simply use FilterableTrait on your Model to filter profanities.

<?php 
...
use Kaankilic\WTFilter\Traits\FilterableWords;
class CustomModel extends Model{
	use FilterableWords;

	public function filterable(){
		return [
        	"sources" => ["title"], // trait gonna check this columns
        	"flag" => "has_profanity" // *optionally you can set flag to any column
    	];
    }
...

Contributions

I am the creator and single contributor of the project. So, Feel free to contribute something useful. Please use Github for reporting bugs, and making comments or suggestions