PHP code example of tedon / laravel-actor

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

    

tedon / laravel-actor example snippets


Schema::table('users', function (Blueprint $table) {
    ...
    $table->actor('test');
    ...
});

Schema::table('users', function (Blueprint $table) {
    ...
    $table->creator();
    $table->editor();
    ...
});

return [
    'custom-macros' => [
        'edit',
        'approve',
    ]
];

use \Tedon\LaravelActor\Traits\Actorable;

class User
{
    use Actorable;
    
    public function actorable(): array
    {
        return [
            'actions' => [
                'edit'
            ]
        ];
    } 
}

getActorId(string $action): int|string;

//  example output: 13

getActorType(string $action): ?string;

//  example output: "\App\Models\User"

getActedAt(string $action): ?Carbon;

//  example output: "2023-04-30 15:30:04"

getActor(string $action): ?Model;

getAct(string $action): array;

//  example output: [
//    'editor_id' => 13,
//    'editor_type' => "\App\Models\User",
//    'edited_at' => "2023-04-30 15:30:04",
//  ]


touchAction(string $action, bool $isForce = false): void;

cleanAction(string $action): void;

isActedBy(string $action, ?Authenticatable $user): bool;

$query
...
    ->actedBy('create', $user)
...