Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

454
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda