Mercurial > packages > framework
changeset 7:e6132a1e8e24 default tip
Adding better support for test among other base changes.
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Thu, 25 Sep 2025 19:58:32 -0400 |
| parents | 6ded573b0a61 |
| children | |
| files | publishable/resources/js/ServerTable.js publishable/resources/js/app.js src/Models/BaseModel.php src/Tests/TestCase.php |
| diffstat | 4 files changed, 39 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/publishable/resources/js/ServerTable.js Tue Sep 09 15:49:54 2025 -0400 +++ b/publishable/resources/js/ServerTable.js Thu Sep 25 19:58:32 2025 -0400 @@ -8,6 +8,7 @@ * @param {Array} [options.initialSort=[]] - Default sort: [{col, dir}] * @param {Object} [options.headers={}] - Additional headers for requests * @param {string} [options.groupBy={}] - Which column to group by + * @param {Function} [options.postRender={}] - Function to call after rendering * @param {Function} [options.groupRender={}] - Function to render the grouping */ constructor(rootEl, options) { @@ -20,6 +21,7 @@ this.currentPage = 1; this.headers = options.headers || {}; this.groupBy = options.groupBy; + this.postRender = options.postRender || null ; this.groupRender = options.groupRender || ((g, rows) => @@ -201,7 +203,9 @@ ) .join(""); } + if(typeof this.postRender === "function") this.postRender(); } + renderError() { this.tbody.innerHTML = `<tr><td colspan="${this.columns.length}" style="color:red">${this.state.error}</td></tr>`; }
--- a/publishable/resources/js/app.js Tue Sep 09 15:49:54 2025 -0400 +++ b/publishable/resources/js/app.js Thu Sep 25 19:58:32 2025 -0400 @@ -3,3 +3,4 @@ import * as popperjs from '@popperjs/core' import * as bootstrap from 'bootstrap' +window.bootstrap = bootstrap;
--- a/src/Models/BaseModel.php Tue Sep 09 15:49:54 2025 -0400 +++ b/src/Models/BaseModel.php Thu Sep 25 19:58:32 2025 -0400 @@ -2,15 +2,15 @@ namespace Wizard\Framework\Models; -use Wizard\Framework\Traits\Filterable; +use Illuminate\Database\Eloquent\Model; use Wizard\Framework\Database\Builder; -use Illuminate\Database\Eloquent\Model; +use Wizard\Framework\Traits\Filterable; class BaseModel extends Model { use Filterable; - protected static string $builder = Builder::class; + protected static string $builder = Builder::class; protected $default_relations = []; @@ -19,16 +19,19 @@ parent::boot(); self::creating(function ($item) { - $item->created_by = \Auth::user()?->id ?? ''; - $item->updated_by = \Auth::user()?->id ?? ''; + if ($user_id = (\Auth::user()->id ?? null)) { + $item->created_by = $user_id; + $item->updated_by = $user_id; + } }); self::saving(function ($item) { - $item->updated_by = \Auth::user()?->id ?? ''; + if ($user_id = (\Auth::user()->id ?? null)) { + $item->updated_by = $user_id; + } }); } - protected static function load_auxilary_data() { $data = []; @@ -59,9 +62,10 @@ return static::load_auxilary_data(); } - public static function named_joins() { - return []; - } + public static function named_joins() + { + return []; + } /** * Retrieve a query builder instance with default relations loaded.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Tests/TestCase.php Thu Sep 25 19:58:32 2025 -0400 @@ -0,0 +1,20 @@ +<?php + +namespace Wizard\Framework\Tests; + +use App\Models\User; +use Illuminate\Foundation\Testing\TestCase as BaseTestCase; +use Illuminate\Foundation\Testing\RefreshDatabase; + +class TestCase extends BaseTestCase { + use RefreshDatabase; + + protected function setUp(): void + { + parent::setUp(); + + // Set a default testing user + $user = User::factory()->create(); + $this->actingAs($user); + } +}
