PHP code example of inisiatif / laravel-budget

1. Go to this page and download the library: Download inisiatif/laravel-budget 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/ */

    

inisiatif / laravel-budget example snippets




declare(strict_types=1);

return [
    /**
     * This is connection database must be available in database config
     */
    'connection' => env('LARAVEL_BUDGET_ELOQUENT_CONNECTION', env('DB_CONNECTION', 'sqlite')),

    /**
     * This is table name for budget
     */
    'table' => env('LARAVEL_BUDGET_ELOQUENT_TABLE', 'budgets'),

    /**
     * Indicated must be running migration, internally used in testing
     */
    'migration' => env('LARAVEL_BUDGET_ELOQUENT_MIGRATION', false),

    /**
     * Column name mapping, you can change this value is column name is different
     */
    'columns' => [
        'id' => 'id',
        'code' => 'code',
        'description' => 'description',
        'total_amount' => 'total_amount',
        'usage_amount' => 'usage_amount',
        'is_over' => 'is_over',
    ],

    /**
     * Column type for version column
     *
     * Support: int, string, json
     */
    'version_column_type' => 'int',

    /**
     * Column version name
     */
    'version_column_name' => 'year',

    /**
     * For json type fill using json path, ex : `version->year`
     */
    'version_json_column_path' => null,

    /**
     * Disable or enable timestamps in model
     */
    'model_uses_timestamps' => true,
];

use Inisiatif\LaravelBudget\LaravelBudget;

LaravelBudget::useBudgetModelClass('Acme\Models\Budget');

'columns' => [
    'id' => 'id',
    'code' => 'code',
    'description' => 'description',
    'total_amount' => 'total_amount',
    'usage_amount' => 'usage_amount',
    'is_over' => 'is_over',
],

// File routes/api.php

use Inisiatif\LaravelBudget\LaravelBudget;

LaravelBudget::routes();

// Sebelumnya anda harus menganbil budget dari database

$budget->increaseUsage(1000); // Untuk menambah penggunaan anggaran sebanyak 1000
$budget->decreaseUsage(500); // Untuk mengurasi penggunaan anggaran sebanyak 500
bash
php artisan vendor:publish --tag="budget-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="budget-config"