Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

paulocorazza's avatar

Get selected option value

I have an edit form to edit my printers, everytime i hit the submit button, i'm also creating a new PrinterChange and i send the informations via email. Here is my controller:

public function update($id, Request $request)
{
    $printer = Printer::find($id);
    $printer->status = $request->status;
    $printer->location = $request->location;
    $changes = $request->status;
    $printer->save();
    //aqui cria um registro no histórico da impressora
    PrinterChange::create($request->all());
    MailerController::composeEmail($request);
    Sweetalert::success('Impressora alterada com sucesso!', 'Sucesso!');
    return to_route('printers.index');
    
}

and here is my blade file:

@extends('layouts.app') @section('content')

        <div class="mb-3">
          <label for="type" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Tipo:</label>
          <input type="text" class="form-control" disabled value="{{ $printer->type }}">
        </div>
    
        <div class="mb-3">
          <label for="model" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Modelo da impressora:</label>
          <input type="text" class="form-control" disabled value="{{ $printer->model }}">
        </div>

        <div class="mb-3">
            <label for="status" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Status:</label>
          <select name="status"
              class="form-control">
              <option selected>{{ $printer->status }}</option>
              <option value="production">Em produção</option>
              <option value="backup">Em Backup<option>
              <option value="maintenance">Em Manutenção<option>
              <option value="grave">Cemitério<option>
          </select>
          </div>
       
        <div class="mb-3">
          <label for="owner" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Quem presta suporte:</label>
          <input type="text" class="form-control" disabled value="{{ $printer->owner }}">
        </div>
        <div class="mb-3">
          <label for="label" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Número de
            Patrimônio Joyson:</label>
        <input type="text" value="{{ $printer->joyson_label }}"  name="joyson_label"
            class="form-control"
           disabled />
        </div>
        <div class="mb-3">
          <label for="local" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Local de instalação:</label>
          <input type="text" value="{{ $printer->location }}" name="location"
              class="form-control"
              placeholder="Ex: L090_EPK_SB"  />
        </div>
        <hr>
       <a class="btn btn-primary" href="/printers">Voltar</a>
       <button type="submit" class="btn btn-success">Salvar</button>
      </form>
    </div>
</div>

The hidden inputs are used to compose my email, and in the input name="changes"

i want the option i 've changed in my select to send it correctly via email

0 likes
2 replies
Arya_Appaji's avatar

PrinterChange::create($request->all())

Try using update instead of create in the above line

Please or to participate in this conversation.