Последняя версия с сервера прошлого разработчика
This commit is contained in:
2
nova-components/NovaLeader/.gitignore
vendored
Executable file
2
nova-components/NovaLeader/.gitignore
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
/dist
|
||||
29
nova-components/NovaLeader/composer.json
Executable file
29
nova-components/NovaLeader/composer.json
Executable file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "ysv/nova-leader",
|
||||
"description": "A Laravel Nova card.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"nova"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=7.1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ysv\\NovaLeader\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Ysv\\NovaLeader\\CardServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
15100
nova-components/NovaLeader/package-lock.json
generated
Executable file
15100
nova-components/NovaLeader/package-lock.json
generated
Executable file
File diff suppressed because it is too large
Load Diff
19
nova-components/NovaLeader/package.json
Executable file
19
nova-components/NovaLeader/package.json
Executable file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^5.0.0",
|
||||
"laravel-mix": "^1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^2.5.0"
|
||||
}
|
||||
}
|
||||
3
nova-components/NovaLeader/resources/js/card.js
vendored
Executable file
3
nova-components/NovaLeader/resources/js/card.js
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
Nova.booting((Vue, router, store) => {
|
||||
Vue.component('NovaLeader', require('./components/Card'))
|
||||
})
|
||||
54
nova-components/NovaLeader/resources/js/components/Card.vue
Executable file
54
nova-components/NovaLeader/resources/js/components/Card.vue
Executable file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<card class="flex flex-col items-center justify-center">
|
||||
<div class="px-3 py-3 w-full">
|
||||
<h1 class="text-center text-3xl text-80 font-light">
|
||||
Лидеры <small>(режим {{ mode ? 'paid' : 'free' }})</small>
|
||||
</h1>
|
||||
<ul v-if="mode">
|
||||
<li v-for="leader in users" :key="leader.user_id"
|
||||
class="mt-3"
|
||||
>
|
||||
<span><small>(id: {{ leader.user_id }})</small> {{ leader.user.first_name }} {{ leader.user.last_name }}</span> - <span>Username: <a :href="`/profile/${leader.user.username}`">{{ leader.user.username }}</a></span> <br><span>Кол.-во голосов:{{ leader.vote_count }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ul v-else>
|
||||
<li v-for="user in users" :key="user.id"
|
||||
class="mt-3"
|
||||
>
|
||||
<span><small>(id: {{ user.id }})</small> {{ user.name }}</span> - <span>Username: <a :href="`/profile/${user.username}`">{{ user.username }}</a></span> <br><span>Кол.-во голосов:{{ user.countVote }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 v-if="mode" class="mt-6">
|
||||
Общая сумма: {{ amount }}
|
||||
</h2>
|
||||
</div>
|
||||
</card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: [
|
||||
'card',
|
||||
|
||||
// The following props are only available on resource detail cards...
|
||||
// 'resource',
|
||||
// 'resourceId',
|
||||
// 'resourceName',
|
||||
],
|
||||
|
||||
data(){
|
||||
return {
|
||||
users: [],
|
||||
amount:0,
|
||||
mode: true,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.users = this.card.leaders
|
||||
this.amount = this.card.amount
|
||||
this.mode = this.card.mode
|
||||
},
|
||||
}
|
||||
</script>
|
||||
1
nova-components/NovaLeader/resources/sass/card.scss
vendored
Executable file
1
nova-components/NovaLeader/resources/sass/card.scss
vendored
Executable file
@@ -0,0 +1 @@
|
||||
// Nova Card CSS
|
||||
19
nova-components/NovaLeader/routes/api.php
Executable file
19
nova-components/NovaLeader/routes/api.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Card API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you may register API routes for your card. These routes
|
||||
| are loaded by the ServiceProvider of your card. You're free to add
|
||||
| as many additional routes to this file as your card may require.
|
||||
|
|
||||
*/
|
||||
|
||||
// Route::get('/endpoint', function (Request $request) {
|
||||
// //
|
||||
// });
|
||||
54
nova-components/NovaLeader/src/CardServiceProvider.php
Executable file
54
nova-components/NovaLeader/src/CardServiceProvider.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Ysv\NovaLeader;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Nova\Events\ServingNova;
|
||||
use Laravel\Nova\Nova;
|
||||
|
||||
class CardServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->app->booted(function () {
|
||||
$this->routes();
|
||||
});
|
||||
|
||||
Nova::serving(function (ServingNova $event) {
|
||||
Nova::script('nova-leader', __DIR__.'/../dist/js/card.js');
|
||||
Nova::style('nova-leader', __DIR__.'/../dist/css/card.css');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the card's routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function routes()
|
||||
{
|
||||
if ($this->app->routesAreCached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Route::middleware(['nova'])
|
||||
->prefix('nova-vendor/nova-leader')
|
||||
->group(__DIR__.'/../routes/api.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
52
nova-components/NovaLeader/src/NovaLeader.php
Executable file
52
nova-components/NovaLeader/src/NovaLeader.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Ysv\NovaLeader;
|
||||
|
||||
use App\Domain\Subscriptions\Service\SubscriptionService;
|
||||
use App\Models\User;
|
||||
use Laravel\Nova\Card;
|
||||
|
||||
class NovaLeader extends Card
|
||||
{
|
||||
/**
|
||||
* The width of the card (1/3, 1/2, or full).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $width = '1/3';
|
||||
|
||||
public $height = 'fixed';
|
||||
|
||||
public function currentLeader()
|
||||
{
|
||||
$mode = nova_get_setting('vote_paid_mode');
|
||||
$leader_count = nova_get_setting('vote_leader_count');
|
||||
|
||||
if($mode){
|
||||
$leaders = collect(SubscriptionService::leaders())->take($leader_count);
|
||||
$ids = $leaders->pluck('user_id');
|
||||
$users = User::whereIn('id', $ids)->get();
|
||||
$leaderUsers = $leaders->map(function($item) use($users) {
|
||||
$item->user = $users->where('id', $item->user_id)->first()->only(['id', 'first_name', 'last_name', 'username']);
|
||||
return $item;
|
||||
});
|
||||
}else{
|
||||
$leaderUsers = SubscriptionService::freeLeaders();
|
||||
}
|
||||
|
||||
|
||||
$amount = SubscriptionService::amount();
|
||||
|
||||
return $this->withMeta(['leaders' => $leaderUsers, 'amount' => $amount, 'mode' => (boolean) $mode]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the component name for the element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function component()
|
||||
{
|
||||
return 'nova-leader';
|
||||
}
|
||||
}
|
||||
6
nova-components/NovaLeader/webpack.mix.js
vendored
Executable file
6
nova-components/NovaLeader/webpack.mix.js
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
let mix = require('laravel-mix')
|
||||
|
||||
mix
|
||||
.setPublicPath('dist')
|
||||
.js('resources/js/card.js', 'js')
|
||||
// .sass('resources/sass/card.scss', 'css')
|
||||
Reference in New Issue
Block a user