russofinn/laravel-interactions

A very simple package to record user interactions on your website or application.

0.0.1 2018-09-04 16:53 UTC

This package is auto-updated.

Last update: 2024-11-07 16:36:55 UTC


README

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads

O pacote russofinn/laravel-interactions fornece funções fáceis de usar para interações dos usuários em seu aplicativo

Aqui está uma demonstração de como você pode usá-lo:

interactions()->comment('Look, I said something.');

Você pode recuperar todas as interações usando o model Russofinn\Interactions\Models\Comment,Russofinn\Interactions\Models\Like, Russofinn\Interactions\Models\View e Russofinn\Interactions\Models\Mention.

Documentation

Você encontrará a documentação sobre https://docs.spatie.be/laravel-activitylog/v2.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the activity log? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a security issue please mail freek@spatie.be instead of using the issue tracker.

Installation

Você pode instalar o pacote via composer

composer require russofinn/laravel-interactions

O pacote será registrado automaticamente.

Você pode publicar os migrations com:

php artisan vendor:publish --provider="Russofinn\Interactions\InteractionsServiceProvider" --tag="migrations"

Nota: O migrations padrão assume que você esteja usando números inteiros para seus IDs. Se você estiver usando UUIDs ou algum outro formato, ajuste o formato dos campos subject_id e causer_id nos migrations antes de continuar.

Depois de publicar os migrations, você pode criar as tabelas comments,likes,views e mentions executando o seguinte comando:

php artisan migrate

Você pode, opcionalmente, publicar o arquivo de configuração com:

php artisan vendor:publish --provider="Russofinn\Interactions\InteractionsServiceProvider" --tag="config"

Este é o conteúdo do arquivo de configuração publicado:

return [
    /*
     * You can specify an auth driver here that gets user models.
     * If this is null we'll use the default Laravel auth driver.
     */
    'default_auth_driver' => null,
    /*
     * If set to true, the subject returns soft deleted models.
     */
    'subject_returns_soft_deleted_models' => false,

    'mentions' => [
        /*
         * If set to true, the subject returns soft deleted models.
         */
        'character' => '@',
        'regex' => '/\s({character}{pattern}{rules})/',
        'regex_replacement' => [
            '{character}' => '@',
            '{pattern}' => '[A-Za-z0-9]',
            '{rules}' => '{4,20}'
        ],

        /*
         * Model that will be mentioned.
         */
        'model' => 'App\User',

        /*
         * The column that will be used to search the model by the parser.
         */
        'column' => 'username',

        /*
         * The route used to generate the user link when mention
         */
        'route' => '/users/profile/@'
    ],

    /*
     * This model will be used to log activity. The only requirement is that
     * it should be or extend the Russofinn\Interactions\Models\Commenty model.
     */
    'comment_model' => \Russofinn\Interactions\Models\Comment::class,

    /*
     * This model will be used to log activity. The only requirement is that
     * it should be or extend the Russofinn\Interactions\Models\Like model.
     */
    'like_model' => \Russofinn\Interactions\Models\Like::class,

    /*
     * This model will be used to log activity. The only requirement is that
     * it should be or extend the Russofinn\Interactions\Models\View model.
     */
    'view_model' => \Russofinn\Interactions\Models\View::class,

    /*
     * This model will be used to log activity. The only requirement is that
     * it should be or extend the Russofinn\Interactions\Models\Mention model.
     */
    'mention_model' => \Russofinn\Interactions\Models\Mention::class,

    /*
     * This is the name of the table that will be created by the migration and
     * used by the Comment model shipped with this package.
     */
    'table_name_comments' => 'comments',

    /*
     * This is the name of the table that will be created by the migration and
     * used by the View model shipped with this package.
     */
    'table_name_mentions' => 'mentions'

    /*
     * This is the name of the table that will be created by the migration and
     * used by the Like model shipped with this package.
     */
    'table_name_likes' => 'likes',

    /*
     * This is the name of the table that will be created by the migration and
     * used by the View model shipped with this package.
     */
    'table_name_views' => 'views'
];

Changelog

Acompanhe o CHANGELOG para maiores informações sobre as alterações recentes.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

Se você descobrir algum problema relacionado à segurança, envie um e-mail para almeida.weslley577@gmail.com em vez de abrir um ISSUE.

Credits

License

Este pacote está diponibilizado sob MIT License (MIT). Leia Arquivo de Licença para maiores informações.