承接 khant-nyar/service-extender 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

khant-nyar/service-extender

最新稳定版本:v1.0.1

Composer 安装命令:

composer require khant-nyar/service-extender

包简介

Creating a service base crud quickly

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

  • ✅ Improved Type Safety – Helps with debugging and prevents invalid data types.
  • ✅ IDE-Friendly Navigation – Ctrl+Click methods to jump to service class.
  • ✅ Automatic Transactions – Prevents database inconsistencies.
  • ✅ Logging Enabled – Tracks changes for debugging.
  • ✅ Easily Extendable – New services can override methods as needed.

Installation

You can install the package via composer:

composer require khant-nyar/service-extender

Usage

/** 
 * Example uses with UserService 
 */

namespace App\Services;

use App\Models\User;
use KhantNyar\ServiceExtender\Services\EloquenceService;

class UserService extends EloquenceService
{
    protected static string $model = User::class;
}

it will generate automacally for UserService::all(),find($id),create($data)

/**
 * Example uses in controller
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Services\UserService;

class UserController extends Controller
{
    public function index()
    {
        return response()->json(UserService::all());
    }

    public function show($id)
    {
        return response()->json(UserService::find((int) $id));
    }

    public function store(Request $request)
    {
        $data = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|email|unique:users',
            'password' => 'required|min:6'
        ]);

        return response()->json(UserService::create($data), 201);
    }

    public function update(Request $request, $id)
    {
        $data = $request->validate([
            'name' => 'sometimes|string|max:255',
            'email' => 'sometimes|email|unique:users,email,' . $id,
            'password' => 'sometimes|min:6'
        ]);

        return response()->json(UserService::update((int) $id, $data));
    }

    public function destroy($id)
    {
        return response()->json(['success' => UserService::delete((int) $id)]);
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email khantnyar.dev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

  • 总下载量: 1.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-15