jangraviren/laravel-survey 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jangraviren/laravel-survey

Composer 安装命令:

composer require jangraviren/laravel-survey

包简介

Original credits goes to mceaser/laravel-survey.

README 文档

README

Goes to mceaser/laravel-survey
Just made this package to use in 5.7.* version.

Add question to your Laravel application

Latest Version on Packagist Build Status Total Downloads

This package allows you to add a survey to your Laravel application

Once installed you can do stuff like this:

// Get all question that a user has
Question::answered(false)->get()

Installation

Laravel

This package can be used in Laravel 5.4 or higher. If you are using an older version of Laravel You can install the package via composer:

composer require jangraviren/laravel-survey

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:

'providers' => [
    // ...
    JangraViren\Survey\SurveyServiceProvider::class,
];

You can publish the migration with:

php artisan vendor:publish --provider="JangraViren\Survey\SurveyServiceProvider" --tag="migrations"

After the migration has been published you can create the category-, question- and answer-tables by running the migrations:

php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="JangraViren\Survey\SurveyServiceProvider" --tag="config"

When published, the config/survey.php config file contains:

return [

    'models' => [

        /*
         * We need to know which Eloquent model should be used to retrieve your categories.
         * Of course, it is often just the "Category" model but you may use whatever you like.
         *
         * The model you want to use as a Category model needs to implement the
         * `JangraViren\Survey\Contracts\Category` contract.
         */

        'category' => JangraViren\Survey\Models\Category::class,

        /*
         * We need to know which Eloquent model should be used to retrieve your questions.
         * Of course, it is often just the "Question" model but you may use whatever you like.
         *
         * The model you want to use as a Question model needs to implement the
         * `JangraViren\Survey\Question\Category` contract.
         */

        'question' => JangraViren\Survey\Models\Question::class,

        /*
         * We need to know which Eloquent model should be used to retrieve your answers.
         * Of course, it is often just the "Answer" model but you may use whatever you like.
         *
         * The model you want to use as a Answer model needs to implement the
         * `JangraViren\Survey\Question\Answer` contract.
         */

        'answer' => JangraViren\Survey\Models\Answer::class,

        /*
         * We need to know which Eloquent model should be used to assign the answers to.
         * Of course, it is often just the "User" model but you may use whatever you like.
         */

        'user' => App\User::class,

    ],
];

Lumen

Lumen support is not tested!

You can install the package via Composer:

composer require jangraviren/laravel-survey

Copy the required files:

cp vendor/jangraviren/laravel-survey/config/permission.php config/survey.php
cp vendor/jangraviren/laravel-survey/database/migrations/create_survey_tables.php.stub database/migrations/2018_01_01_000000_create_survey_tables.php

Now, run your migrations:

php artisan migrate

Then, register the configuration and the service provider:

$app->configure('survey');
$app->register(JangraViren\Survey\SurveyServiceProvider::class);

Usage

The models supplied by this package can be used the same as any other model you make.

Extending

If you need to EXTEND the existing models note that:

  • Your Category model needs to extend the JangraViren\Survey\Models\Category model
  • Your Question model needs to extend the JangraViren\Survey\Models\Question model
  • Your Answer model needs to extend the JangraViren\Survey\Models\Answer model

If you need to REPLACE the existing models you need to keep the following things in mind:

  • Your Category model needs to implement the JangraViren\Survey\Contracts\Category contract
  • Your Question model needs to implement the JangraViren\Survey\Contracts\Question contract
  • Your Answer model needs to implement the JangraViren\Survey\Contracts\Answer contract

In BOTH cases, whether extending or replacing, you will need to specify your new models in the configuration. To do this you must update the models.categorie, models.question and models.answer values in the configuration file after publishing the configuration with this command:

php artisan vendor:publish --provider="JangraViren\Survey\SurveyServiceProvider" --tag="config"

Testing

composer test

Credits

License

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

jangraviren/laravel-survey 适用场景与选型建议

jangraviren/laravel-survey 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「survey」 「laravel」 「question」 「answer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jangraviren/laravel-survey 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jangraviren/laravel-survey 我们能提供哪些服务?
定制开发 / 二次开发

基于 jangraviren/laravel-survey 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-19