douglas-spindola / laravel-inspiring-quotes
一个为Laravel提供鼓舞人心的引语的包
0.1.1
2024-09-04 19:49 UTC
This package is not auto-updated.
Last update: 2024-09-19 18:12:00 UTC
README
这是一个简单的Laravel包,为您的应用程序提供鼓舞人心的引语。轻松地将有意义的引语集成到Laravel项目中,用智慧和积极性提升用户体验。
安装
您可以通过Composer安装此包
composer require douglas-espindola/laravel-motivational-quotes
使用方法
安装包后,您可以通过导入Inspiring类并调用quoteInPortuguese方法来开始使用它
use DouglasSpindola\LaravelInspiringQuotes\Inspiring; $quote = Inspiring::quoteInPortuguese(); echo $quote;
Inertia.js示例
如果您使用Inertia.js,可以将引语传递给前端组件,如下所示
Route::get('/dashboard', function () { return Inertia::render('Dashboard', [ 'quote' => Inspiring::quoteInPortuguese(), ]); })->middleware(['auth', 'verified'])->name('dashboard');
然后在您的Dashboard组件中
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; import { Head } from '@inertiajs/react'; import Inspire from "@/Pages/Inspire.jsx"; export default function Dashboard({ auth, quote }) { return ( <AuthenticatedLayout user={auth.user} header={<h2 className="font-semibold text-xl text-gray-800 leading-tight">Dashboard</h2>} > <Head title="Dashboard" /> <div className="py-12"> <div className="max-w-7xl mx-auto sm:px-6 lg:px-8"> <div className="bg-white overflow-hidden shadow-sm sm:rounded-lg"> <div className="p-6 text-gray-900"><Inspire quote={quote} /></div> </div> </div> </div> </AuthenticatedLayout> ); }
自定义
您可以通过添加自己的引语来自定义此包。只需修改Inspiring类中的quotes方法,并将新引语添加到数组中。这些引语将被随机选择并显示
protected static function quotes() { return Collection::make([ 'Your new custom quote here.', // Add more quotes here... ]); }
贡献
欢迎贡献!如果您有任何建议或发现问题,请随意在GitHub仓库中发起拉取请求或提交问题。
许可证
此包是开源软件,根据MIT许可证授权。
