laravel controller 如何插入一个没有自增的id?

laravel controller how to insert an id without auto increment?

        $category = new HmsBbrCategory;
        $category->category_name = $request->input('category_name');
        $category->category_description = $request->input('category_description');
        $category->save();
        
        $category->category_id = $category->id;
        $category->save();

我有这个 table,只有 id 设置为非空。我需要在不使用自动增量的情况下插入列,我应该向我的函数添加什么?

我正在考虑计算 ID 并添加 +1,以便数字按顺序排列:

$category->id = id()->count()+1;

虽然这条线不算数

从数据库中获取最后一个 ID

$categoryId=HmsBbrCategory::orderByDesc('id')->first();

$autoIncId=$categoryId->id+1;

$category = new HmsBbrCategory;
$category->category_name = $request->input('category_name');
$category->category_description = $request->input('category_description');
$category->id=$autoIncId;
$category->category_id =$autoIncId;
$category->save();