Bristol SU Support Package
Log.php
Go to the documentation of this file.
1 <?php
2 
4 
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 }
option(string $key, $default=null)
Definition: Action.php:74
static failure(string $message='')
static success(string $message='')