the Form Mode allow you run your Tinker code with form.
Write the Tinker code normally, and name the variable that needs to be converted into a form with a prefix.
for example:
$form_email = '[email protected]';
$form_password = 'secret';
$user = User::where('email', $form_email)->first();
$user->password = bcrypt($form_password);
$user->save();
$user;
the code will create two text fields in the form
example:
$form_email = [
'label' => 'Email',
'description' => 'the email field description',
'value' => '[email protected]',
'type' => 'text',
]
value
is requiredtype
can betext
email
number
etc, it’s same with<input/>
type property
also you can just use
$form_email = '[email protected]';
is same as
$form_email = [
'value' => '[email protected]',
];
example:
$form_lang = [
'label' => 'Language',
'description' => 'the language you should choose',
'value' => 'golang',
'type' => 'select',
'options' => [
[
'label' => 'PHP',
'value' => 'php',
],
[
'label' => 'C++',
'value' => 'cplusplus',
],
[
'label' => 'Go',
'value' => 'golang',
]
]
];
value
is requiredtype
should beselect
options
is same with the<option/>
tag in<select/>
example:
$form_is_admin = [
'label' => 'Is Admin',
'description' => 'the user is admin or not',
'value' => false,
'type' => 'checkbox',
]
value
is required, and must betrue
orfalse
type
should becheckbox
the default prefix is form_
, and you can also define yours in the VScode setinggs