本文整理汇总了PHP中DataForm::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DataForm::create方法的具体用法?PHP DataForm::create怎么用?PHP DataForm::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataForm
的用法示例。
在下文中一共展示了DataForm::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVehicle
public function getVehicle($id)
{
if (Auth::user()->isAdmin()) {
$device = Device::find($id);
$vehicles = Vehicle::whereHas('Account', function ($query) {
$query->where('company_id', Auth::user()->company_id);
})->doesntHave('Device')->get()->lists("fullname", "id")->all();
$form = \DataForm::create();
$form->add('device_id', '', 'hidden')->insertValue($id);
$form->add('device_name', 'Aparelho', 'text')->insertValue($device->name)->mode('readonly');
$form->link('/devices', 'Voltar', 'TR');
if ($device->vehicle_id != '') {
$form->add('vehicle_name', 'Veículo', 'text')->insertValue($device->Vehicle->fullname)->mode('readonly');
$form->add('vehicle_id', '', 'hidden')->insertValue($device->vehicle_id);
$form->add('install_date', 'Data de Instalação', 'date')->format('d/m/Y')->insertValue($device->install_date)->mode('readonly');
$form->textarea('description', 'Observações')->insertValue($device->description)->mode('readonly');
$form->add('action', '', 'hidden')->insertValue('remove');
$form->label('Remover Aparelho');
$form->submit('Confirma Retirada');
} else {
$form->add('vehicle_id', 'Veículo', 'select')->option("", "Selecione")->options($vehicles)->rule('required');
$form->add('install_date', 'Data de Instalação', 'date')->format('d/m/Y')->rule('required');
$form->textarea('description', 'Observações')->rule('required|min:15');
$form->add('action', '', 'hidden')->insertValue('assign');
$form->label('Instalar Aparelho');
$form->submit('Salvar');
}
return $form->view('devices::vehicle', compact('form'));
} else {
return $form->view('errors.503');
}
}
示例2: getArguments
public function getArguments(Request $request)
{
$device_id = $request->device_id;
$device = Device::find($device_id);
$id_command = $request->id_command;
$names = config('commands_names');
$template = config('commands_syntax.' . $id_command);
$form = \DataForm::create();
$form->add('device_id', '', 'hidden')->insertValue($device_id);
$form->add('device_name', 'Aparelho', 'text')->insertValue($device->serial)->mode('readonly');
$form->add('type', '', 'hidden')->insertValue(array_get($template, 'TYPE'));
$form->link("/commands/send/{$device_id}", 'Voltar', 'TR')->back();
$form->label($names[$id_command]);
$params = array_get($template, 'PARAMETERS');
$p = 0;
foreach ($params as $param) {
$form->add('PAR_' . $p, '', 'hidden')->insertValue($param['ID']);
if ($param['VALUE'] !== '') {
if (is_array($param['VALUE'])) {
$form->add('VAL_' . $p, $param['LABEL'], 'select')->options($param['VALUE']);
} else {
$form->add('VAL_' . $p, '', 'hidden')->insertValue($param['VALUE']);
}
} else {
$form->add('VAL_' . $p, $param['LABEL'], 'text');
}
$p++;
}
$form->add('param_count', '', 'hidden')->insertValue($p);
//dd($template);
$form->submit('Salvar');
return $form->view('commands::edit', compact('form'));
}
示例3: getpassword
public function getpassword()
{
$form = \DataForm::create();
$form->add('user_id', '', 'hidden')->insertValue(Auth::user()->id);
$form->add('old_password', 'Senha Antiga', 'password');
$form->add('password', 'Senha Nova', 'password');
$form->add('password_confirmation', 'Confirme a Senha', 'password');
$form->label('Alterar Senha');
$form->submit('Atualizar');
$form->build();
return $form->view('user.password', compact('form'));
}