Skip to content
Tech Master Tech Master

OneStopTechnical Forum

  • Books
  • AI
  • Networking
  • Windows
  • Linux
  • Cloud
  • Mac
  • Active Directory
  • Azure
  • Cloud
  • Exchange
  • M365
  • Server 2025
  • Storage
  • Vsphere
  • Website
  • Database
  • Security
  • Knowledge Base
  • VPN
Tech Master
Tech Master

OneStopTechnical Forum

Deep Dive: Adding Custom Fields to Snipe-IT (Database + UI)

blog.payperitem.com, April 3, 2025

1️⃣ Database Modification: Add a New Column

Snipe-IT uses MySQL/MariaDB as its database. First, we need to add a new field to store the additional data.

📝 Create a Migration for the New Field

Run the following command in your Snipe-IT installation directory:

sh
php artisan make:migration add_warranty_expiry_to_assets --table=assets

Open the generated migration file in database/migrations/ and modify it:

phpuse Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up()
{
Schema::table('assets', function (Blueprint $table) {
$table->date('warranty_expiry')->nullable()->after('purchase_date');
});
}

public function down()
{
Schema::table('assets', function (Blueprint $table) {
$table->dropColumn('warranty_expiry');
});
}
};

Now, apply the migration:

shCopyEditphp artisan migrate

2️⃣ Modify the Asset Model

To allow Laravel to interact with this new field, update the Asset model.

📝 Modify app/Models/Asset.php

Add the new field to the $fillable array:

php
protected $fillable = ['name', 'serial', 'purchase_date', 'warranty_expiry', ...];

3️⃣ Modify the Backend Controller

If we want the UI to display and edit the new field, update the API controller.

📝 Modify app/Http/Controllers/API/AssetController.php

Ensure the field is included in the response:

phppublic function show($id)
{
return response()->json(Asset::findOrFail($id));
}

public function update(Request $request, $id)
{
$asset = Asset::findOrFail($id);
$asset->update($request->only(['warranty_expiry']));
return response()->json($asset);
}

4️⃣ Modify Blade Templates (UI Update)

Snipe-IT uses Laravel Blade templates for some UI elements. We need to update these views.

📝 Modify resources/views/assets/form.blade.php

Add a new input field inside the <form> section:

html<div class="form-group">
<label for="warranty_expiry">Warranty Expiry Date</label>
<input type="date" class="form-control" name="warranty_expiry" value="{{ old('warranty_expiry', $asset->warranty_expiry ?? '') }}">
</div>

5️⃣ Modify Vue.js Components for UI

Snipe-IT uses Vue.js for asset management. We need to modify Vue components to display the new field.

📝 Modify resources/js/components/assets/EditAsset.vue

Locate the form section and add:

vue<template>
<div>
<!-- Other asset fields -->
<div class="form-group">
<label for="warranty_expiry">Warranty Expiry Date</label>
<input type="date" class="form-control" v-model="asset.warranty_expiry" />
</div>
</div>
</template>

<script>
export default {
data() {
return {
asset: {
warranty_expiry: '' // Initialize the field
}
};
},
methods: {
saveAsset() {
axios.put(`/api/v1/hardware/${this.asset.id}`, this.asset)
.then(response => {
this.$emit('saved', response.data);
})
.catch(error => {
console.error(error);
});
}
}
}
</script>

6️⃣ Rebuild the Frontend

Since we modified Vue components, we need to recompile the assets.

sh
cd /var/www/snipe-it
npm install
npm run dev # or npm run prod for production

7️⃣ Restart Services

Clear caches and restart relevant services:

shphp artisan config:clear
php artisan cache:clear
php artisan queue:restart
systemctl restart nginx # or Apache

✅ The New Field is Now Integrated!

What we achieved: ✅ Database updated to store the field.
✅ Backend model & API updated to process the new field.
✅ Blade templates & Vue.js UI modified to display the field.
✅ Frontend rebuilt & services restarted for deployment.

Cloud Linux OpenSource Website

Post navigation

Previous post
Next post

Related Posts

Snipe-IT is an open-source IT asset management system

April 3, 2025April 3, 2025

Snipe-IT is an open-source IT asset management system that runs on a LAMP/LEMP stack. Below are the steps to install Snipe-IT on Ubuntu (22.04 or later). Step 1: Update and Install Dependencies bashsudo apt update && sudo apt upgrade -ysudo apt install -y apache2 mariadb-server php php-cli php-mbstring php-xml php-bcmath…

Read More

O365 policy framework for roaming users

April 11, 2025April 11, 2025

When managing roaming users in Microsoft 365 (Office 365)—users who regularly work outside of the corporate network or move between locations/devices—it’s essential to implement policies that balance security, accessibility, and productivity. 🔐 1. Identity & Access Management 💼 2. Device Management (MDM/MAM) 🧳 3. Data Loss Prevention (DLP) 📨 4….

Read More

ESXi 7.0 → 8.0Upgrading from VMware ESXi 6.0 to 8.0ESXi 7.0 → 8.0

April 3, 2025April 3, 2025

Upgrading from VMware ESXi 6.0 to 8.0 is a multi-step process, as ESXi 6.0 is not directly upgradable to ESXi 8.0. You must first upgrade to ESXi 6.7 or 7.0, and then proceed to 8.0. Step 1: Pre-Upgrade Checks ✅ Verify Hardware Compatibility ✅ Check Existing vCenter Version ✅ Backup…

Read More

Recent Posts

  • List of AD Schema Versions
  • OldNewExplorer Free Download For Windows 11, 10, 8 and 7 [Latest Version]
  • How to Get the Classic (old) Context Menu on Windows 11
  • BitLocker Recovery Keys
  • Active Directory and Server hardening

Recent Comments

No comments to show.
June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« May    
Log in
©2025 Tech Master | WordPress Theme by SuperbThemes
  • Login
  • Sign Up
Forgot Password?
Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.
body::-webkit-scrollbar { width: 7px; } body::-webkit-scrollbar-track { border-radius: 10px; background: #f0f0f0; } body::-webkit-scrollbar-thumb { border-radius: 50px; background: #dfdbdb }