Skip to content

Instantly share code, notes, and snippets.

@czemu
Created March 4, 2020 19:08
Show Gist options
  • Save czemu/26386449cc366054162422e347a01f2c to your computer and use it in GitHub Desktop.
Save czemu/26386449cc366054162422e347a01f2c to your computer and use it in GitHub Desktop.
<?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