Actions

Want custom action ? Custom action may be generated using the atomic:action Artisan command. By default, all new actions will be placed in the app/Atomic/Actions directory of your application:

php artisan atomic:action SetDefaultVersion
1

SetDefaultVersion.php

The class generated by the atomic:action Artisan command , you can find this class in app/Atomic/Actions

use MustafaKhaled\AtomicPanel\ActionMessage;
use MustafaKhaled\AtomicPanel\AtomicModelAction;
use MustafaKhaled\AtomicPanel\AtomicPanel;

class SetDefaultVersion extends AtomicModelAction
{

    /**
     * @param $model
     * @return \Illuminate\Http\RedirectResponse|null
     */
    public function handle($model)
    {
        $mainClass = AtomicPanel::$atomicModels[$model->AtomicBaseName()];
        foreach ($mainClass::get() as $item) {
            $item->default_version = 0;
            $item->save();
        }
        $model->default_version = 1;
        $model->save();
        ActionMessage::make(__("Version ($model->name) is the default Version now"))->success();
        return redirect()->back();

    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

ActionMessage

Want to show action message for user ? you can use ActionMessage class with the type of the message.

Success Message

ActionMessage::make(__("Success Message"))->success();
1

Danger Message

ActionMessage::make(__("Danger Message"))->danger();
1

Error Message

ActionMessage::make(__("Error Message"))->error();
1