Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
How to check if user has selected multiple checkboxes

I am working on a Laravel 5.8 project which is an Online Store. and in this project, I wanted to add "Printing Order Factors" feature for Admins.

So I have made a form like this:

<form method="POST" action="{{ route('orders.newprint') }}">
    @csrf
    @forelse($orders as $order)
    <tr>
        <td><input class="form-check-input" name="orderCheck[]" type="checkbox" value="{{ $order->ord_id }}">&nbsp;</td>
        <td>{{ $order->ord_id }}</td>
        <td>{{ $order->status_label }}</td>
        <td>{{ $order->customer_name }}</td>
        <td>{{ $order->ord_total }}</td>
    </tr>
    @empty
        <td colspan="7" class="text-center">No order to show</td>
    @endforelse
</form>

So basically admins can select multiple orders like this:

enter image description here

And I'm trying to send order ids as an array:

<input class="form-check-input" name="orderCheck[]" type="checkbox" value="{{ $order->ord_id }}">

Now at the Controller, I need to check if user has selected multiple orders or not

public function prnpriview(Request $request)
    {
        if(!empty($request->input('actions'))){
            if($request->input('actions')=='print_factors'){
                if(USER SELECTES MORE THAN ONE CHECKBOX) { 
                    ...
                    return view('admin.shop.orders.newprint', compact('args'));
                }else{
                    return back();
                }
            }
        }else{
            return back();
        }
    }

So how to check if user has selected multiple checkboxes (more than one checkbox) or not ?

I would really appreciate any idea or suggestion from you guys about this...

Thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

$request->orderCheck will be in an array, so you can use count()

$checked = $request->input('orderCheck',[]);// if checkbox is not checked than return empty array
if(count($checked) > 1) { 
    return view('admin.shop.orders.newprint', compact('args'));
}else{
    return back();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda