filter method on custom Actions (CP)

Hello people!

We have built an Action according to the documentation () for blocking users. So we want the action to be available at the CP for User-entities only. However the filter method is not called, so we have no influence over this issue. Any expertise from the Statamic community here? I'd appreciate.

Here you see my PHP, initialised via command line.

<?php

namespace App\Actions;

use Statamic\Actions\Action;
use Illuminate\Support\Facades\Log;
use App\Mail\NotifyBlock;
use Illuminate\Support\Facades\Mail;
use Statamic\Contracts\Auth\User;
use Statamic\Contracts\Entries\Entry;

class BlockUser extends Action
{

    public function filter($item)
    {
        Log::info('filtering');
        return $item instanceof User;
    }

    /**
     * The run method
     *
     * @return void
     */
    public function run($items, $values)
    {
       foreach($items as $user)
       {
            $user   ->roles(['blocked'])
                    ->save();

            $email = $user->email();

            $firstName = $user->get('first_name');
            $surName = $user->get('last_name');

            Mail::to($email)
            ->send(new NotifyBlock(
                $firstName, $surName
            ));

       }
    }

}

best regards,

Nils

Answered by Nils Siemsen!
>>>>>>> Answered <<<<<<<
3 Replies
2 Followers