Skip to content

Commit b5fe26a

Browse files
authored
Merge pull request #157 from fleetbase/dev-v1.6.17
Dev v1.6.17
2 parents 745290b + 9d03d2a commit b5fe26a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6673
-430
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/core-api",
3-
"version": "1.6.16",
3+
"version": "1.6.17",
44
"description": "Core Framework and Resources for Fleetbase API",
55
"keywords": [
66
"fleetbase",
@@ -40,7 +40,7 @@
4040
"laravel-notification-channels/fcm": "^4.1",
4141
"laravel-notification-channels/twilio": "^3.3",
4242
"laravel/sanctum": "3.2.4",
43-
"lcobucci/clock": "^3.3",
43+
"lcobucci/clock": "3.3.1",
4444
"lcobucci/jwt": "^5.4",
4545
"maatwebsite/excel": "^3.1",
4646
"phpoffice/phpspreadsheet": "^1.28",
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('reports', function (Blueprint $table) {
16+
$table->string('public_id')->unique()->after('uuid');
17+
$table->string('description')->nullable()->after('title');
18+
$table->string('status')->nullable()->after('body');
19+
$table->json('tags')->nullable()->after('body');
20+
$table->json('meta')->nullable()->after('body');
21+
$table->json('options')->nullable()->after('body');
22+
$table->json('query_config')->nullable()->after('body');
23+
$table->json('result_columns')->nullable()->after('query_config');
24+
$table->timestamp('last_executed_at')->nullable()->after('result_columns');
25+
$table->integer('execution_time')->nullable()->comment('Execution time in milliseconds')->after('last_executed_at');
26+
$table->integer('row_count')->nullable()->after('execution_time');
27+
$table->boolean('is_scheduled')->default(false)->after('row_count');
28+
$table->json('schedule_config')->nullable()->after('is_scheduled');
29+
$table->json('export_formats')->nullable()->after('schedule_config');
30+
$table->boolean('is_generated')->default(false)->after('export_formats');
31+
$table->index(['company_uuid', 'is_scheduled']);
32+
$table->index('last_executed_at');
33+
});
34+
}
35+
36+
/**
37+
* Reverse the migrations.
38+
*
39+
* @return void
40+
*/
41+
public function down()
42+
{
43+
Schema::table('reports', function (Blueprint $table) {
44+
// Drop indexes first
45+
$table->dropIndex(['company_uuid', 'is_scheduled']);
46+
$table->dropIndex(['last_executed_at']);
47+
48+
// Drop columns
49+
$table->dropColumn([
50+
'public_id',
51+
'description',
52+
'status',
53+
'meta',
54+
'tags',
55+
'options',
56+
'query_config',
57+
'result_columns',
58+
'last_executed_at',
59+
'execution_time',
60+
'row_count',
61+
'is_scheduled',
62+
'schedule_config',
63+
'export_formats',
64+
'is_generated',
65+
]);
66+
});
67+
}
68+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::create('report_cache', function (Blueprint $table) {
16+
$table->id();
17+
$table->uuid('uuid')->unique();
18+
$table->uuid('report_uuid');
19+
$table->string('cache_key')->unique();
20+
$table->longText('cached_data');
21+
$table->json('metadata')->nullable();
22+
$table->integer('row_count')->default(0);
23+
$table->integer('execution_time')->nullable();
24+
$table->timestamp('expires_at')->nullable();
25+
$table->timestamps();
26+
27+
// Indexes
28+
$table->index('report_uuid');
29+
$table->index('cache_key');
30+
$table->index('expires_at');
31+
32+
// Foreign key constraint
33+
$table->foreign('report_uuid')->references('uuid')->on('reports')->onDelete('cascade');
34+
});
35+
}
36+
37+
/**
38+
* Reverse the migrations.
39+
*
40+
* @return void
41+
*/
42+
public function down()
43+
{
44+
Schema::dropIfExists('report_cache');
45+
}
46+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::create('report_audit_logs', function (Blueprint $table) {
16+
$table->id();
17+
$table->uuid('uuid')->unique();
18+
$table->uuid('report_uuid')->nullable();
19+
$table->uuid('user_uuid');
20+
$table->uuid('company_uuid');
21+
$table->string('action'); // execute, export, create, update, delete, schedule
22+
$table->string('status'); // success, failed, pending
23+
$table->json('query_config')->nullable();
24+
$table->json('metadata')->nullable(); // Additional context data
25+
$table->text('error_message')->nullable();
26+
$table->integer('execution_time')->nullable();
27+
$table->integer('row_count')->nullable();
28+
$table->string('export_format')->nullable();
29+
$table->string('ip_address')->nullable();
30+
$table->string('user_agent')->nullable();
31+
$table->timestamps();
32+
33+
// Indexes
34+
$table->index(['company_uuid', 'action']);
35+
$table->index(['user_uuid', 'action']);
36+
$table->index(['report_uuid', 'action']);
37+
$table->index(['status', 'created_at']);
38+
$table->index('created_at');
39+
40+
// Foreign key constraints
41+
$table->foreign('report_uuid')->references('uuid')->on('reports')->onDelete('set null');
42+
$table->foreign('user_uuid')->references('uuid')->on('users')->onDelete('cascade');
43+
$table->foreign('company_uuid')->references('uuid')->on('companies')->onDelete('cascade');
44+
});
45+
}
46+
47+
/**
48+
* Reverse the migrations.
49+
*
50+
* @return void
51+
*/
52+
public function down()
53+
{
54+
Schema::dropIfExists('report_audit_logs');
55+
}
56+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::create('report_templates', function (Blueprint $table) {
16+
$table->id();
17+
$table->uuid('uuid')->unique();
18+
$table->string('public_id')->unique();
19+
$table->string('name');
20+
$table->text('description')->nullable();
21+
$table->string('category')->default('custom');
22+
$table->json('query_config');
23+
$table->json('default_parameters')->nullable();
24+
$table->json('required_parameters')->nullable();
25+
$table->boolean('is_public')->default(false);
26+
$table->boolean('is_system')->default(false);
27+
$table->uuid('company_uuid')->nullable();
28+
$table->uuid('created_by_uuid');
29+
$table->uuid('updated_by_uuid')->nullable();
30+
$table->integer('usage_count')->default(0);
31+
$table->timestamp('last_used_at')->nullable();
32+
$table->timestamps();
33+
$table->softDeletes();
34+
35+
// Indexes
36+
$table->index(['company_uuid', 'category']);
37+
$table->index(['is_public', 'category']);
38+
$table->index(['is_system', 'category']);
39+
$table->index('created_by_uuid');
40+
$table->index('usage_count');
41+
$table->index('last_used_at');
42+
43+
// Foreign key constraints
44+
$table->foreign('company_uuid')->references('uuid')->on('companies')->onDelete('cascade');
45+
$table->foreign('created_by_uuid')->references('uuid')->on('users')->onDelete('cascade');
46+
$table->foreign('updated_by_uuid')->references('uuid')->on('users')->onDelete('set null');
47+
});
48+
}
49+
50+
/**
51+
* Reverse the migrations.
52+
*
53+
* @return void
54+
*/
55+
public function down()
56+
{
57+
Schema::dropIfExists('report_templates');
58+
}
59+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*/
11+
public function up(): void
12+
{
13+
Schema::create('report_executions', function (Blueprint $table) {
14+
$table->id();
15+
$table->uuid('uuid')->unique();
16+
$table->uuid('report_uuid');
17+
$table->uuid('user_uuid')->nullable();
18+
$table->uuid('company_uuid')->nullable();
19+
$table->decimal('execution_time', 10, 2)->nullable()->comment('Execution time in milliseconds');
20+
$table->integer('result_count')->default(0);
21+
$table->json('query_config')->nullable();
22+
$table->enum('status', ['pending', 'running', 'completed', 'failed'])->default('pending');
23+
$table->text('error_message')->nullable();
24+
$table->timestamp('started_at')->nullable();
25+
$table->timestamp('completed_at')->nullable();
26+
$table->timestamps();
27+
28+
// Indexes
29+
$table->index('report_uuid');
30+
$table->index('user_uuid');
31+
$table->index('status');
32+
$table->index('started_at');
33+
$table->index(['report_uuid', 'status']);
34+
35+
// Foreign key constraints
36+
$table->foreign('report_uuid')->references('uuid')->on('reports')->onDelete('cascade');
37+
$table->foreign('user_uuid')->references('uuid')->on('users')->onDelete('set null');
38+
$table->foreign('company_uuid')->references('uuid')->on('companies')->onDelete('set null');
39+
});
40+
}
41+
42+
/**
43+
* Reverse the migrations.
44+
*/
45+
public function down(): void
46+
{
47+
Schema::dropIfExists('report_executions');
48+
}
49+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*/
11+
public function up(): void
12+
{
13+
Schema::table('custom_fields', function (Blueprint $table) {
14+
$table->string('for')->after('type')->nullable()->index();
15+
});
16+
}
17+
18+
/**
19+
* Reverse the migrations.
20+
*/
21+
public function down(): void
22+
{
23+
Schema::table('custom_fields', function (Blueprint $table) {
24+
$table->dropIndex(['for']);
25+
$table->dropColumn(['for']);
26+
});
27+
}
28+
};

src/Auth/Schemas/IAM.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class IAM
4444
'name' => 'policy',
4545
'actions' => ['export'],
4646
],
47+
[
48+
'name' => 'report',
49+
'actions' => ['export', 'execute'],
50+
],
4751
];
4852

4953
/**

src/Casts/Money.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ public function set($model, $key, $value, $attributes)
3232
if ($value === null) {
3333
return 0;
3434
}
35+
3536
$value = static::removeCurrencySymbols($value);
3637
$value = static::removeSpecialCharactersExceptDotAndComma($value);
37-
if (is_float($value) || Str::contains($value, '.')) {
38-
$value = number_format((float) $value, 2, '.', '');
39-
}
38+
// if (is_float($value) || Str::contains($value, '.')) {
39+
// $value = number_format((float) $value, 2, '.', '');
40+
// }
4041

4142
return Utils::numbersOnly($value);
4243
}
@@ -49,11 +50,12 @@ public static function apply($value): int
4950
if ($value === null) {
5051
return 0;
5152
}
53+
5254
$value = static::removeCurrencySymbols($value);
5355
$value = static::removeSpecialCharactersExceptDotAndComma($value);
54-
if (is_float($value) || Str::contains($value, '.')) {
55-
$value = number_format((float) $value, 2, '.', '');
56-
}
56+
// if (is_float($value) || Str::contains($value, '.')) {
57+
// $value = number_format((float) $value, 2, '.', '');
58+
// }
5759

5860
return Utils::numbersOnly($value);
5961
}

0 commit comments

Comments
 (0)