Bristol SU Support Package
src
Action
Actions
Log.php
Go to the documentation of this file.
1
<?php
2
3
namespace
BristolSU\Support\Action\Actions
;
4
5
use
BristolSU\Support\Action\Contracts\Action
;
6
use
BristolSU\Support\Action\ActionResponse
;
7
use
FormSchema\Generator\Field
;
8
use
FormSchema\Schema\Form
;
9
15
class
Log
extends
Action
16
{
17
21
public
function
run
():
ActionResponse
22
{
23
try
{
24
\Illuminate\Support\Facades\Log::info($this->
option
(
'text'
));
25
}
catch
(\
Exception
$e) {
26
return
ActionResponse::failure
(($e->getMessage() ===
''
?
'Could not log the text'
: $e->getMessage()));
27
}
28
return
ActionResponse::success
(
'Text saved to the log file'
);
29
}
30
34
public
static
function
options
(): Form
35
{
36
return \FormSchema\Generator\Form::make()->withField(
37
Field::input(
'text'
)->inputType(
'text'
)->label(
'Message'
)
38
->required(
true
)->
default
(
''
)->hint(
'The message to save to the log'
)
39
->help(
'When triggered, this message will be saved to the php logs'
)
40
)->getSchema();
41
}
42
}
BristolSU\Support\Action\Contracts\Action\option
option(string $key, $default=null)
Definition:
Action.php:74
BristolSU\Support\Action\ActionResponse\failure
static failure(string $message='')
Definition:
ActionResponse.php:77
Field
Form
BristolSU\Support\Action\Actions\Log
Definition:
Log.php:15
BristolSU\Support\Action\Actions
Definition:
Log.php:3
ActionResponse
BristolSU\Support\Action\Actions\Log\run
run()
Definition:
Log.php:21
BristolSU\Support\Action\ActionResponse
Definition:
ActionResponse.php:5
BristolSU\Support\Action\Contracts\Action
Definition:
Action.php:17
Action
BristolSU\Support\Action\ActionResponse\success
static success(string $message='')
Definition:
ActionResponse.php:63
BristolSU\Support\Action\Actions\Log\options
static options()
Definition:
Log.php:34
Exception
Generated by
1.8.13