Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

455
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!