Action Last updated: 2022-10-04

Sometimes, in some cases, we need to take an action

Then you will be confused how to do this, but be aware that it is a wonderful thing that we will be exposed to

Let me give you an example of the status of members
To activate and deactivate one or more members

First we need to create a new Action object

php artisan dash:make-action UserStatus
UserStatus Action generated

this is object  created in app\Dash\Actions path

<?php
namespace App\Dash\Actions;
use Dash\Extras\Inspector\Action;

class UserStatus extends Action {

	/**
	 * options to do some action with type message 
	 * like danger,info,warning,success
	 * @return array
	 */ 
	public static function options() {
		//Example
		return [
			'account_status' => [
				'active' => [
					'success' => 'user is activeated successfully',
   				],
				'deactivate' => [
					'danger' => 'deactivate successfully',
				] 
			],
		];
	}

}

columns => account_status

value (active , deactivate) 

message style you can use danger,info,warning,success 

success to show success message

warning to show warning message

info to show info message

danger to show danger message 

After the object is finished you can add it inside your resource in the actions method

public function actions() {
		return [
			\App\Dash\Actions\UserStatus::class,
		];
}