1. Go to this page and download the library: Download patrixsmart/adjustfly 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/ */
patrixsmart / adjustfly example snippets
use Illuminate\Database\Eloquent\Model;
use Patrixsmart\Adjustfly\Concerns\HasAdjustments;
class Student extends Model
{
use HasAdjustments;
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use Patrixsmart\Adjustfly\Concerns\OwnedAdjustments;
class User extends Authenticatable
{
use OwnedAdjustments;
}
$user->ownedAdjustments; // everything this user changed
$user->paginatedOwnedAdjustments(25);
use Patrixsmart\Adjustfly\Models\Adjustment;
$student->adjustments; // newest first
$student->latestAdjustment; // single most recent
$student->paginatedAdjustments(25);
$student->simplePaginatedAdjustments(25);
Adjustment::query()->forAdjustable($student)->get();
Adjustment::query()->forType(Student::class)->get();
Adjustment::query()->forUser($user)->get();
$adjustment->changedAttributes(); // ['name', 'email']
$adjustment->before; // cast to array
$adjustment->user; // the acting user
$adjustment->adjustable; // the adjusted model
use Patrixsmart\Adjustfly\Events\AdjustmentRecorded;
Event::listen(function (AdjustmentRecorded $event) {
// $event->adjustment, $event->adjustable
});
use Patrixsmart\Adjustfly\Models\Adjustment;
class AdjustmentPolicy
{
public function viewAny(User $user): bool
{
return $user->isAdmin();
}
public function view(User $user, Adjustment $adjustment): bool
{
return $user->isAdmin();
}
}
// AppServiceProvider::boot()
Gate::policy(Adjustment::class, AdjustmentPolicy::class);