PHP code example of a2zwebltd / laravel-feature-voting

1. Go to this page and download the library: Download a2zwebltd/laravel-feature-voting library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

a2zwebltd / laravel-feature-voting example snippets


'admin_email' => env('FEATURE_VOTING_ADMIN_EMAIL'),
'admin_gate' => 'manage-feature-requests',
'routes' => [
    'enabled' => true,
    'prefix' => 'feature-requests',
    'middleware' => ['web', 'auth'],
],
'views' => [
    'layout' => 'feature-voting::layouts.default',  // point at your own layout
    'section' => 'content',
],
'livewire' => ['register' => true],

// app/Providers/AppServiceProvider.php — boot()
use Illuminate\Support\Facades\Gate;
use App\Models\User;

Gate::define('manage-feature-requests', function (User $user) {
    return in_array($user->email, ['[email protected]']);
    // or $user->is_admin, or a role check, etc.
});

'views' => [
    'layout' => 'layouts.app',   // your existing layout
    'section' => 'content',       // the @yield name inside it
],

use A2ZWeb\FeatureVoting\Services\FeatureVotingService;
use A2ZWeb\FeatureVoting\Enums\FeatureRequestStatus;

$service = app(FeatureVotingService::class);

$request = $service->submit($user, 'Add Slack export', 'Would love this');
$service->toggleVote($user, $request);
$service->comment($user, $request, 'Same here!');
$service->updateStatus($admin, $request, FeatureRequestStatus::Planned, 'Targeting Q3');
$service->isAdmin($user);

use A2ZWeb\FeatureVoting\Events\FeatureRequestCreated;
use Illuminate\Support\Facades\Event;

Event::listen(FeatureRequestCreated::class, function ($event) {
    // ping Slack, create a JIRA ticket, etc.
});

// config/feature-voting.php
'routes' => ['enabled' => false, /* ... */],
bash
php artisan vendor:publish --tag=feature-voting-config
php artisan vendor:publish --tag=feature-voting-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=feature-voting-views