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

453
Vistas
Call to undefined function App\Http\Controllers\array_except() in laravel

In my laravel application, I have an option to update user details, following is the update function in my controller

public function update(Request $request, $id)

    {

        $this->validate($request, [

            'name' => 'required',

            'email' => 'required|email|unique:users,email,'.$id,

            'password' => 'same:confirm-password',

            'comp_id'=>'required',

            'roles' => 'required'

        ]);

    

        $input = $request->all();

        if(!empty($input['password'])){ 

            $input['password'] = Hash::make($input['password']);

        }else{

            $input = array_except($input,array('password'));    

        }

    

        $user = User::find($id);

        $user->update($input);

        DB::table('model_has_roles')->where('model_id',$id)->delete();

    

        $user->assignRole($request->input('roles'));

    

        return redirect()->route('customers.index')

                        ->with('success','Customer updated successfully');

    }

But when I try to execute the above function am getting an error saying,

Call to undefined function App\Http\Controllers\array_except() 

I used the exac same code in the other update functions as well, but they worked without an issue..

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

0

Solution 1:

use Illuminate\Support\Arr;

$array = ['name' => 'Desk', 'price' => 100];

$filtered = Arr::except($array, ['price']);

Reference: https://laravel.com/docs/6.x/helpers#method-array-except

Solution 2:

Starting Laravel 6, most of the str_ & array_ helpers funcs are accessible ONLY by the new laravel/helpers composer package, if you don't have this package you'll get this sort of error.

Install helpers' package:

composer require laravel/helpers

and

composer dump-autoload
over 4 years ago · Santiago Trujillo Denunciar

0

Include use Illuminate\Support\Arr; in your code and change:

$input = array_except($input,array('password'));

to

$input = Arr::except($input,array('password'));

array_except() is deprecated in versions greater than 5.8 for laravel

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