PHP code example of aseven-team / laravel-accounting

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

    

aseven-team / laravel-accounting example snippets


return [
];

use Aseven\Accounting\Models\Account;
use Aseven\Accounting\Enums\AccountType;
use AsevenTeam\LaravelAccounting\Enums\NormalBalance;

Account::create([
    'code' => '1-1001',
    'name' => 'Cash',
    'type' => AccountType::Asset,
    'normal_balance' => NormalBalance::Debit,
    'parent_id' => null, // optional
    'is_active' => true, // optional
    'description' => 'Cash in hand', // optional
]);

transaction()
    ->setDate(now())
    ->withDescription('Buy raw material')
    ->addLine(account: '1-1001', debit: 0, credit: 1000)
    ->addLine(account: '5-1001', debit: 1000, credit: 0)
    ->save()
bash
php artisan vendor:publish --tag="laravel-accounting-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-accounting-config"