PHP code example of kamranahmedse / laravel-censor

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

    

kamranahmedse / laravel-censor example snippets


    'replace' => [
	    'idiot'    => '(not a nice word)',
	    'hate%'    => 'peace',      // Wildcard: Will replace the words beginning at hate e.g. hatered, hate, hated etc
	    '%eograph%' =>  'some-graphy-word',         // Willcard: Will replace words containing `eograph` anywhere in the middle e.g. geographic, angeography etc
	    'seventh'  => '7th',
	    'monthly'  => 'every month',
	    'yearly'   => 'every year',
	    'weekly'   => 'every week',
    ],
    

    'redact' => [
       'idiot%',        // e.g. idiot will be replaced with 5 asterisks, idiotic with 7 asterisks etc 
       'password',      // Will be replaced with 8 asterisks
       'word-that-i-really-dislike',
    ],
    

   Route::get('post-detail', ['middleware' => 'censor', 'uses' => 'PostController@detail', 'as' => 'postDetail']);
   

    Route::group(['prefix' => 'post', 'middleware' => 'censor'], function () {
	    Route::get('detail', ['uses' => 'PostController@detail']);
	    Route::get('add', ['uses' => 'PostController@add']);
    });
    

    'providers' => array(
        ....
        KamranAhmed\LaravelCensor\LaravelCensorServiceProvider::class,
    ),
    
shell
    php artisan vendor:publish