• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

SUKOHI/Maven: A Laravel package to manage FAQ.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

SUKOHI/Maven

开源软件地址(OpenSource Url):

https://github.com/SUKOHI/Maven

开源编程语言(OpenSource Language):

PHP 70.0%

开源软件介绍(OpenSource Introduction):

Maven

A Laravel package to manage FAQ.
(This package is for Laravel 5.3+)

Demo

'Example'

Requirements

Installation

Execute the next command.

composer require sukohi/maven:4.*

Set the service providers in app.php

'providers' => [
    ...Others...,
    Collective\Html\HtmlServiceProvider::class,
    Sukohi\Cahen\CahenServiceProvider::class,
    Sukohi\Maven\MavenServiceProvider::class,
]

Also alias

'aliases' => [
    ...Others...,
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    'Cahen'   => Sukohi\Cahen\Facades\Cahen::class,
    'Maven'   => Sukohi\Maven\Facades\Maven::class,
]

Then execute the next commands.

php artisan vendor:publish
php artisan migrate

Usage (Management page)

Set Maven::route() in your routes.php.

\Sukohi\Maven\Maven::route();

// or with default locale

\Sukohi\Maven\Maven::route('en');

Now you can access to http(s)://YOUR-DOMAIN/admin/maven.
Note: I believe that you need to authenticate in routes.php before calling Maven::route() using middleware or something.

[Config]
After publishing, you should have maven.php in your config folder.
you can set some values in the file like the followings.

locales

First of all, you have only en locale.
You can add more locales if you want like so.

'locales' => [
    'en' => 'English',
    'ja' => 'Japanese',
    'es' => 'Spanish'
],

// or

'locales' => [
    'ja' => '日本語',
    'en' => '英語',
    'es' => 'スペイン語'
],

// The keys and values refer locale symbols and language names.

URI

The default value is admin/maven.
So http(s)://YOUR-DOMAIN/admin/maven is the URL for managing FAQs.

Per Page

You can change maximum records per page.

Usage (Retrieve data)

[Basic Way]

$faqs = \Maven::get();

foreach ($faqs as $faq) {

    if($faq->hasLocale('en')) {

        // FAQ
        echo $faq->getQuestion('en');
        echo $faq->getRawQuestion('en');
        echo $faq->getAnswer('en');
        echo $faq->getRawAnswer('en');
        
        // Tag(s)
        $tags = $faq->getTags('en');    // Collection
        
        // Others
        echo $faq->sort_id;
        echo $faq->unique_key;
        echo $faq->created_at;
        echo $faq->updated_at;
        
    }

}

[Filtering]

Tag(s)

$faqs = \Maven::tag([
    'en' => 'YOUR-TAG'
])->get();

// or

$faqs = \Maven::tag([
    'en' => ['YOUR-TAG', 'YOUR-TAG'],
    'ja' => 'タグ'
])->get();

(Raminsadeghi indecated an error here for me. Thank you for kind of you!)

Unique Key

$faq = \Maven::uniqueKey('952557a09ef19aae1d9e2a276db18a66')->first();

// or 

$faqs = \Maven::uniqueKey([
    '952557a09ef19aae1d9e2a276db18a66', 
    'fashrtrhstgrfaeargthukfyhdredeff', 
])->get();

Pagination

{!! $faqs->links() !!}

All Tag(s)

$tags = \Maven::getAllTags();

// or with $draft_filter_flag

$tags = \Maven::getAllTags($draft_filter_flag = true);

In this case, if you'd like to get en tag(s), you should call like so.

$english_tags = $tags['en'];

Model Instance

In order to get model instance of this package, you can use getModel().

\Maven::getModel('unique_key');
\Maven::getModel('faq');
\Maven::getModel('tag');

Export/Import

You can two commands for export/import.

[Export]

php artisan maven:export
  • Exported file is located at storage/app/maven/maven_faqs.json, storage/app/maven/maven_tags.json and storage/app/maven/maven_unique_keys.json.

[Import]

php artisan maven:import

Contributor

PapaDragonov

License

This package is licensed under the MIT License.
Copyright 2016 Sukohi Kuhoh




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap