diff --git a/.php_cs b/.php_cs
index 0a31335..43e3bf0 100644
--- a/.php_cs
+++ b/.php_cs
@@ -1,4 +1,5 @@
notPath('bootstrap/cache')
->notPath('storage')
diff --git a/app/Blade/Directives/Icon.php b/app/Blade/Directives/Icon.php
index c37f370..3a65aae 100644
--- a/app/Blade/Directives/Icon.php
+++ b/app/Blade/Directives/Icon.php
@@ -1,4 +1,4 @@
-";
+ public static function register()
+ {
+ Blade::directive('icon', function ($icon) {
+ $icon = str_replace('\'', '"', $icon);
+
+ return "";
});
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/app/Http/Controllers/Api/Datatable/Manage/UserController.php b/app/Http/Controllers/Api/Datatable/Manage/UserController.php
index dde416f..abf7ff9 100644
--- a/app/Http/Controllers/Api/Datatable/Manage/UserController.php
+++ b/app/Http/Controllers/Api/Datatable/Manage/UserController.php
@@ -4,12 +4,16 @@
use App\Http\Controllers\Controller;
use App\Models\User;
+use App\Transformers\Datatable\UserTransformer;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function __invoke(Request $request)
{
- return app('datatables')->eloquent(User::datatable())->toJson();
+ return app('datatables')
+ ->eloquent(User::datatable())
+ ->setTransformer(new UserTransformer())
+ ->toJson();
}
}
diff --git a/app/Http/Controllers/LanguageController.php b/app/Http/Controllers/LanguageController.php
index 8d0702f..5994887 100644
--- a/app/Http/Controllers/LanguageController.php
+++ b/app/Http/Controllers/LanguageController.php
@@ -9,7 +9,7 @@ class LanguageController extends Controller
public function __invoke(Request $request, $language)
{
app()->setLocale($language);
-
+
swal()->success(
__('Language'),
__('Current application language has been set to ' . __(strtoupper($language)) . '.')
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 91f2897..0985205 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -43,11 +43,6 @@ class Kernel extends HttpKernel
'throttle:60,1',
'bindings',
],
-
- 'datatable' => [
- 'throttle:60,1',
- 'bindings',
- ],
];
/**
@@ -69,6 +64,6 @@ class Kernel extends HttpKernel
'minify' => \App\Http\Middleware\MinifyHtml::class,
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
- 'theme' => \CleaniqueCoders\Themer\Http\Middleware\ThemeLoader::class,
+ 'theme' => \CleaniqueCoders\Themer\Http\Middleware\ThemeLoader::class,
];
}
diff --git a/app/Macros/Http/Response.php b/app/Macros/Http/Response.php
index 5901e9d..790f94d 100644
--- a/app/Macros/Http/Response.php
+++ b/app/Macros/Http/Response.php
@@ -8,7 +8,7 @@ class Response
{
public static function registerMacros()
{
- HttpResponse::macro('api', function ($data, $message = null, $status = true, $code = 200) {
+ HttpResponse::macro('api', function ($data = null, $message = null, $status = true, $code = 200) {
return response()->json([
'data' => $data,
'message' => $message,
diff --git a/app/Observers/ReferenceObserver.php b/app/Observers/ReferenceObserver.php
index b818ce4..aaabf41 100644
--- a/app/Observers/ReferenceObserver.php
+++ b/app/Observers/ReferenceObserver.php
@@ -21,14 +21,14 @@ class ReferenceObserver
*/
public function creating(Model $model)
{
- if (Schema::hasColumn($model->getTable(), 'reference') && is_null($model->reference)) {
- $count = $model::count();
+ $count = method_exists($model, 'getCounter') ? $model->getCounter() : ($model::count() ?? 0);
- $reference = isset($model->reference_prefix) ?
- generate_reference($model->reference_prefix, $count) :
- generate_reference(config('document.prefix'), $count);
+ $column = method_exists($model, 'getReferenceColumn') ? $model->getReferenceColumn() : 'reference';
- $model->reference = $reference;
+ $prefix = method_exists($model, 'referencePrefix') ? $model->referencePrefix() : config('document.prefix');
+
+ if (Schema::hasColumn($model->getTable(), $column) && is_null($model->$column)) {
+ $model->$column = generate_reference($prefix, $count);
}
}
}
diff --git a/app/Providers/BladeServiceProvider.php b/app/Providers/BladeServiceProvider.php
index 2b0c524..858a1ca 100644
--- a/app/Providers/BladeServiceProvider.php
+++ b/app/Providers/BladeServiceProvider.php
@@ -3,26 +3,28 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Support\Facades\Blade;
+/**
+ * @todo To create custom Blade Directives using Blade::component
+ */
class BladeServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
- *
- * @return void
*/
public function boot()
{
\App\Blade\Directives\Icon::register();
+
+ // @todo to figure out, how to pass data to the custom component
+ Blade::component('components.cards.figure', 'figure');
}
/**
* Register services.
- *
- * @return void
*/
public function register()
{
- //
}
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 28d0133..dc912d7 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -68,7 +68,7 @@ protected function mapApiRoutes()
protected function mapDatatableRoutes()
{
Route::prefix('api/datatable')
- ->middleware('datatable')
+ ->middleware('api')
->as('api.datatable.')
->namespace($this->namespace . '\Api\Datatable')
->group(base_path('routes/datatable.php'));
diff --git a/app/Providers/ThemeServiceProvider.php b/app/Providers/ThemeServiceProvider.php
index 342ce5d..5aa49b8 100644
--- a/app/Providers/ThemeServiceProvider.php
+++ b/app/Providers/ThemeServiceProvider.php
@@ -2,10 +2,9 @@
namespace App\Providers;
-use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
-use Illuminate\View\Compilers\Concerns\CompilesLayouts;
use Illuminate\Support\Str;
+use Illuminate\View\Compilers\Concerns\CompilesLayouts;
class ThemeServiceProvider extends ServiceProvider
{
@@ -13,8 +12,6 @@ class ThemeServiceProvider extends ServiceProvider
/**
* Bootstrap services.
- *
- * @return void
*/
public function boot()
{
@@ -23,18 +20,16 @@ public function boot()
/**
* Register services.
- *
- * @return void
*/
public function register()
{
- //
}
/**
* Strip the parentheses from the given expression.
*
- * @param string $expression
+ * @param string $expression
+ *
* @return string
*/
public function stripParentheses($expression)
diff --git a/app/Services/Hashids.php b/app/Services/Hashids.php
index e83a5e6..e9da8a0 100644
--- a/app/Services/Hashids.php
+++ b/app/Services/Hashids.php
@@ -16,7 +16,7 @@ class Hashids
*/
protected $hashids;
- public function __construct($salt, $length, $alphabet)
+ public function __construct(string $salt, int $length, string $alphabet)
{
$this->hashids = new HashidsProvider($salt, $length, $alphabet);
}
@@ -24,10 +24,15 @@ public function __construct($salt, $length, $alphabet)
/**
* Create an instance of Hashids.
*
- * @return App\Services\Hashids
+ * @return static
*/
- public static function make($salt, $length, $alphabet)
+ public static function make(?string $salt, ?int $length, ?string $alphabet)
{
+ $salt = is_null($salt) ? config('hashids.salt') : config('hashids.salt') . $salt;
+ $length = $length ?? config('hashids.length');
+ $alphabet = $alphabet ?? config('hashids.alphabet');
+ $salt = \Illuminate\Support\Facades\Hash::make($salt);
+
return new self($salt, $length, $alphabet);
}
@@ -50,11 +55,11 @@ public function encode(int $value): string
*
* @return int|null
*/
- public function decode(string $value): int
+ public function decode(string $value): ?int
{
$value = $this->hashids->decode($value);
- if (is_array($value)) {
+ if (is_array($value) && sizeof($value) > 0) {
return $value[0];
} else {
return null;
diff --git a/app/Support/helpers.php b/app/Support/helpers.php
index 89adb63..fda332c 100644
--- a/app/Support/helpers.php
+++ b/app/Support/helpers.php
@@ -70,13 +70,8 @@ function generate_reference($prefix = 'DOCUMENT REFERENCE', $count = false)
* Hashids Helper
*/
if (! function_exists('hashids')) {
- function hashids($salt = null, $length = null, $alphabet = null)
+ function hashids(?string $salt = null, ?int $length = null, ?string $alphabet = null): \App\Services\Hashids
{
- $salt = is_null($salt) ? config('hashids.salt') : config('hashids.salt') . $salt;
- $length = is_null($length) ? config('hashids.length') : $length;
- $alphabet = is_null($alphabet) ? config('hashids.alphabet') : $alphabet;
- $salt = \Illuminate\Support\Facades\Hash::make($salt);
-
return \App\Services\Hashids::make($salt, $length, $alphabet);
}
}
diff --git a/app/Transformers/Datatable/UserTransformer.php b/app/Transformers/Datatable/UserTransformer.php
new file mode 100644
index 0000000..f422d1d
--- /dev/null
+++ b/app/Transformers/Datatable/UserTransformer.php
@@ -0,0 +1,23 @@
+ $user->hashslug,
+ 'name' => $user->name,
+ 'email' => $user->email,
+ ];
+ }
+}
diff --git a/config/theme.php b/config/theme.php
index 13f6986..15e330b 100644
--- a/config/theme.php
+++ b/config/theme.php
@@ -1,16 +1,17 @@
- env('THEME_DEFAULT', 'tabler'),
+ /*
+ * Set default theme. Default is Tabler.
+ */
+ 'default' => env('THEME_DEFAULT', 'tabler'),
- /**
- * Available Themes in the application
- * This can be use for switchable theme feature.
- */
- 'themes' => [
- 'tabler'
- ]
-];
\ No newline at end of file
+ /*
+ * Available Themes in the application
+ * This can be use for switchable theme feature.
+ */
+ 'themes' => [
+ 'tabler',
+ ],
+];
diff --git a/phpunit.dusk.xml b/phpunit.dusk.xml
index b0ee354..bbf9d2c 100644
--- a/phpunit.dusk.xml
+++ b/phpunit.dusk.xml
@@ -26,6 +26,5 @@