Skip to content

Instantly share code, notes, and snippets.

@czemu

czemu/BanUser.php Secret

Created Mar 4, 2020
Embed
What would you like to do?
<?php
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Text;
class BanUser extends Action
{
use InteractsWithQueue, Queueable;
/**
* Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model)
{
$model->banAccount($fields->reason);
}
}
/**
* Get the fields available on the action.
*
* @return array
*/
public function fields()
{
return [
Text::make('Reason')
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment