1. Go to this page and download the library: Download inpin/lara-report 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/ */
class Book extends \Illuminate\Database\Eloquent\Model {
use Inpin\LaraReport\Reportable;
}
ReportItem::query()->create([
'type' => 'books',
'title' => 'Price is incorrect',
]);
// Create an empty report by currently logged in user.
$book->createReport();
// Create a report on $book object with "report item id" of 1 and 2, with message of null,
// and put current logged in user form default guard as reporter.
$book->createReport([1, 2]);
// Create a report on $book object with "report item id" of 1 and 2, and put user message of "some message on it",
// and put current logged in user form default guard as reporter.
$book->createReport([1, 2], 'some message');
// Create a report on $book object with "report item id" of 1 and 2, put user message of "some message on it",
// and put current logged in user form 'api' guard as reporter.
$book->createReport([1, 2], 'some message', 'api');
// Create a report on $book object with "report item id" of 1 and 2, put user message of "some message on it",
// and put $user (3rd param) as reporter.
$book->createReport([1, 2], 'some message', $user');
$book->reports(); // HasMany relation to reports of book.
$book->reports; // Collection of book's reports.
$book->isReported() // check if current logged in user form default guard has reported book.
$book->isReported // check if current logged in user form default guard has reported book.
$book->isReported('api') // check if current logged in user form 'api' guard has reported book.
$book->isReported($user) // check if '$user' has reported book.
$book->reportsCount; // return number of reports on $book.
$book->reportsCount(); // return number of reports on $book.
$report->assign(); // Assign current logged from default guard as admin of $report
$report->assign('api'); // Assign current logged from 'api' guard as admin of $report
$report->assign($user); // Assign $user as admin of $report
// set resolved_at with current timestamp and assign current logged from default guard as admin of $report
$report->resolve();
// set resolved_at with current timestamp and assign current logged from 'api' guard as admin of $report
$report->resolve('api');
// set resolved_at with current timestamp and assign $user as admin of $report
$report->resolve($user);
// check if $report is resolved or not.
$report->isResolved();