1 year ago

Display custom error msg

Posted 1 year ago by deepu07

Hey guys, I have one quick question In my laravel project I want to customize findOrFail method error msg. how can I do that? is it a good idea to overwrite/modify core functions of framework?

        $result = $this->find($id, $columns);

        if (is_array($id)) {
            if (count($result) === count(array_unique($id))) {
                return $result;
        } elseif (! is_null($result)) {
            return $result;

        throw (new ModelNotFoundException)->setModel(
            get_class($this->model), $id

I want display `return response()->json(['status'=>'succ' 'msg'='error msg'], 404);` 
any help that would be great. Thanks!

Please sign in or create an account to participate in this conversation.