How to update a table in laravel using a different searching parameter instead of an id?

I’m trying to implement a simple Update form in laravel, but the table field 'id' has to be called 'codigo' instead. The SQL sentence sent to the database searches for an id with the WHERE statement, but I’m not looking for an id but a codigo, and that’s where I don’t know how to change the sql statement.

This is my EstudianteController update function

public function update(Request $request, $codigo)
    {
        $estudiante = Estudiante::where('codigo', $codigo)->firstOrFail();
        
        $request->validate([
            'codigo' => 'required',
            'apellidos' => 'required|string|max:255',
            'nombres' => 'required|string|max:255',
            'edad' => 'required|integer',
            'direccion' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:estudiantes,email,' . $codigo . ',codigo',
            'fechanacimiento' => 'required|date',
        ]);

        $estudiante->update($request->all());
        
        return redirect()->route('estudiantes.index')
            ->with('success', 'Estudiante actualizado correctamente.');
    }

My Estudiante model

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Estudiante extends Model
{
    use HasFactory;

    protected $primarykey = 'codigo';
    public $incrementing = false;

    protected $fillable = [
        'apellidos', 'nombres', 'edad', 'direccion', 'email', 'fechanacimiento'
    ];
}   

And my edit.blade.php form

@extends('layouts.app')

@section('title', 'Editar Estudiante')

@section('content')
    <h1>Editar Estudiante</h1>
    @if ($errors->any())
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif
    <form action="{{ route('estudiantes.update', $estudiante->codigo) }}" method="POST">
        @csrf
        @method('PUT')
        <input type="hidden" name="codigo" id="codigo" value="{{ $estudiante->codigo }}">
        <div>
            <label for="apellidos">Apellidos:</label>
            <input type="text" name="apellidos" id="apellidos" value="{{ old('apellidos', $estudiante->apellidos) }}" required>
        </div>
        <div>
            <label for="nombres">Nombres:</label>
            <input type="text" name="nombres" id="nombres" value="{{ old('nombres', $estudiante->nombres) }}" required>
        </div>
        <div>
            <label for="edad">Edad:</label>
            <input type="number" name="edad" id="edad" value="{{ old('edad', $estudiante->edad) }}" required>
        </div>
        <div>
            <label for="direccion">Dirección:</label>
            <input type="text" name="direccion" id="direccion" value="{{ old('direccion', $estudiante->direccion) }}" required>
        </div>
        <div>
            <label for="email">Email:</label>
            <input type="email" name="email" id="email" value="{{ old('email', $estudiante->email) }}" required>
        </div>
        <div>
            <label for="fechanacimiento">Fecha de Nacimiento:</label>
            <input type="date" name="fechanacimiento" id="fechanacimiento" value="{{ old('fechanacimiento', $estudiante->fechanacimiento) }}" required>
        </div>
        <button type="submit">Actualizar</button>
    </form>
@endsection

The error thrown by laravel is the following:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'
update
  `estudiantes`
SET
  `direccion` = Mar del Plata,
  `estudiantes`.`updated_at` = 2024 -05 -22 17: 31: 34
WHERE
  `id` IS NULL

and I want it to look like this:

update
  `estudiantes`
SET
  `direccion` = Mar del Plata,
  `estudiantes`.`updated_at` = 2024 -05 -22 17: 31: 34
WHERE
  `codigo` IS 4 

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật