Giter Site home page Giter Site logo

reportable's Introduction

Latest Version Total Downloads Software License

Laravel Reportable

This package will allow you to add a full report system into your Laravel application.

Installation

First, pull in the package through Composer.

composer require ghanem/reportable

And then include the service provider within app/config/app.php.

'providers' => [
    Ghanem\Reportable\ReportableServiceProvider::class
];

At last you need to publish and run the migration.

php artisan vendor:publish --provider="Ghanem\Reportable\ReportableServiceProvider"

and

php artisan migrate

Setup a Model

<?php

namespace App;

use Ghanem\Reportable\Contracts\Reportable;
use Ghanem\Reportable\Traits\Reportable as ReportableTrait;
use Illuminate\Database\Eloquent\Model;

class Post extends Model implements Reportable
{
    use ReportableTrait;
}

Examples

The User Model reports the Post Model

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

use App\Post;
use Auth;

class PostController extends Controller
{
    public function makeReport()
    {
        $post = Post::find(1);
        $user = Auth::user();
        
        $post->report([
            'reason' => str_random(10),
            'meta' => ['some more optional data, can be notes or something'],
        ], $user);
    }

Create a conclusion for a Report and add the User Model as "judge" (useful to later see who or what came to this conclusion)

$report->conclude([
    'conclusion' => 'Your report was valid. Thanks! We\'ve taken action and removed the entry.',
    'action_taken' => 'Record has been deleted.' // This is optional but can be useful to see what happend to the record
    'meta' => ['some more optional data, can be notes or something'],
], $user);

Get the conclusion for the Report Model

$report->conclusion;

Get the judge for the Report Model (only available if there is a conclusion)

$report->judge(); // Just a shortcut for $report->conclusion->judge

Get an array with all Judges that have ever "judged" something

Report::allJudges();

reportable's People

Contributors

abdullahghanem avatar dungnh avatar huiyang avatar

Stargazers

MadForCoding avatar Yanik Kumar avatar superern avatar  avatar Luis Gonzalez avatar Tithira Jayasekera avatar Stephen Jude avatar Patrick avatar Solomon avatar  avatar Miguel Lima avatar Hasnat Babur avatar Abdullah Ghanem avatar Van avatar mohammad avatar Erich Garcia Cruz avatar Salahuddin Hairai avatar Mouad Boulahdoud avatar Mohamed H.Fakher avatar İsmail Çakır avatar Tim Joosten avatar Jonathan Iqueda avatar Ahmed Saad avatar Mohamed Abdalmoniem avatar Rumen Rusanov avatar Hasan Abuzayed avatar Michael Chrisco avatar Nick avatar  avatar LogikIO avatar Fabien avatar Matheus Lima avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

reportable's Issues

Laravel 10

Is it possible to update the dependencies to support Laravel 10?

Thanks

I got error ? Help me please upgrade package version

Screenshot 05-23-2024 15 06 39

PHP 8.1.17 (cli) (built: Mar 14 2023 23:07:43) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.17, Copyright (c) Zend Technologies

Laravel Version .......................................................................................................................... 10.48.7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.