incadev-uns/core-domain
Composer 安装命令:
composer require incadev-uns/core-domain
包简介
Core package implementing Incadev's business domain
README 文档
README
This package provides the single source of truth for the Incadev business domain, modeling the shared database schema, and Eloquent models. It ensures all projects built on this platform share the same data structure.
Requirements
- PHP ^8.2
- Laravel ^12.0
Installation
Installing this package is a multi-step process. Please follow these instructions carefully.
1. Install the Package
First, install the incadev-uns/core-domain package via Composer:
composer require incadev-uns/core-domain:dev-main
2. Install Dependencies
This package relies on Laravel Sanctum and Spatie's Laravel-Permission. You must install and configure them first.
Publish Sanctum's configuration and migration
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
Publish Spatie/Permission's configuration and migration
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
3. Run Core Migrations
This package will add all core domain tables and modify your existing users table.
You must run the migrations:
php artisan migrate
4. Configure Your User Model
This is the most critical step. Your app/Models/User.php model must be updated to use the traits and fields provided by this package and its dependencies.
A. Add Traits
Import and use the HasIncadevCore, HasApiTokens, and HasRoles traits.
<?php namespace App\Models; // ... use Illuminate\Foundation\Auth\User as Authenticatable; use Laravel\Sanctum\HasApiTokens; // <-- 1. Import Laravel Sanctum use Spatie\Permission\Traits\HasRoles; // <-- 2. Import Spatie Permission use IncadevUns\CoreDomain\Traits\HasIncadevCore; // <-- 3. Import Incadev Core class User extends Authenticatable { use // ... HasApiTokens, HasRoles, HasIncadevCore; // <-- 4. Use all traits // ...
B. Update $fillable Array
Our migration adds dni, fullname, avatar, and phone to your users table. You must add these to the $fillable array to allow mass assignment.
protected $fillable = [ 'name', 'email', 'password', // --- Add these new fields --- 'dni', 'fullname', 'avatar', 'phone', // ---------------------------- ];
5. Run the Core Seeder
Finally, run the package seeder to populate the database with essential data.
php artisan db:seed --class="IncadevUns\CoreDomain\Database\Seeders\IncadevSeeder"
Usage
The primary purpose of this package is to provide a centralized core domain (Eloquent models and migrations) ready for immediate use. This ensures that all teams and applications within the organization share the same data structure and business logic, preventing you from having to create your own models for common concepts (like students, courses, enrollments, etc.).
A. Using the Package Models
Instead of creating your own models (e.g., App\Models\Enrollment), you should import and use the models provided by this package directly in your controllers, services, and other components.
For example, if you need to manage student profiles or enrollments, you would do so in a controller like this:
<?php namespace App\Http\Controllers; // 1. Import models directly from the package use IncadevUns\CoreDomain\Models\StudentProfile; use IncadevUns\CoreDomain\Models\Enrollment; use Illuminate\Http\Request; class SomeController extends Controller { /** * Display the enrollments for a specific student. */ public function showStudentEnrollments($profileId) { // 2. Use the package model to find the profile $student = StudentProfile::findOrFail($profileId); // 3. Access relationships defined in the package $enrollments = $student->enrollments()->where('status', 'active')->get(); return view('some.view', compact('student', 'enrollments')); } /** * Create a new enrollment. */ public function storeEnrollment(Request $request) { // 4. Use the package models to create new records $enrollment = Enrollment::create([ 'student_profile_id' => $request->student_id, 'course_id' => $request->course_id, 'status' => 'pending', // ... other fields ]); return redirect()->route('home')->with('success', 'Enrollment created.'); } }
B. Accessing Relations from the User Model
As an added benefit, once you have configured the HasIncadevCore trait on your App\Models\User model, you can instantly access all this related data directly from the authenticated user:
$user = Auth::user(); // Get user profiles $studentProfile = $user->studentProfile; $teacherProfile = $user->teacherProfile; // Get academic data $enrollments = $user->enrollments; $certificates = $user->certificates; // Get community data $threads = $user->threads; $comments = $user->comments; // Get support data $tickets = $user->tickets; // Get HR data $contracts = $user->contracts; $applications = $user->applications; // Get appointments $apptsAsStudent = $user->appointmentsAsStudent; $apptsAsTeacher = $user->appointmentsAsTeacher;
C. Using Polymorphic Traits
This package provides powerful traits to add behavior to any model.
CanBeAudited: Allows all actions on a model to be audited.CanBeRated: Allows a model to be rated using the core Survey system.CanBeVoted: Allows a model to be upvoted or downvoted.
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
incadev-uns/core-domain 适用场景与选型建议
incadev-uns/core-domain 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 388 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「core-domain」 「incadev-uns」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 incadev-uns/core-domain 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 incadev-uns/core-domain 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 incadev-uns/core-domain 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Core domain library for all APIs and implementations that are common between all the packages
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
统计信息
- 总下载量: 388
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-02