Compare commits

..

No commits in common. "87cd634613a1bf1f036b747291d78f8d0db9da0f" and "3f340d57fc8e3b9b45fdb6a1ccb634162963b905" have entirely different histories.

13 changed files with 29 additions and 81 deletions

View File

@ -27,6 +27,6 @@ modified="git diff --diff-filter=M --name-only --cached | grep \".php$\""
ignore="resources/lang,resources/views,bootstrap/helpers,database/migrations,bin"
phpcs="vendor/bin/phpcs --report=code --colors --report-width=80 --ignore=${ignore}"
__run "1/2" "php lint" "${modified} | xargs -r php -l"
__run "2/2" "code sniffer" "${modified} | xargs -r ${phpcs}"
__run "1/1" "code sniffer" "${modified} | xargs -r ${phpcs}"
# __run "2/3" "php lint" "${modified} | xargs -r php -l"
# __run "3/3" "phpstan" "${modified} | xargs -r vendor/bin/phpstan analyse"

View File

@ -52,7 +52,7 @@ class CreateUser extends Command
]);
$this->info("$email created successfully.");
return Command::SUCCESS;
return 0;
} catch (\Exception $e) {
$this->error('Unable to create your user.');
$this->line($e->getMessage());

View File

@ -52,7 +52,7 @@ class ResetPassword extends Command
$column = 'email';
$value = $email;
} else {
$column = strtolower($this->choice('What database column would you like to search by?', ['ID', 'Email']));
$column = strtolower($this->choice('What column would you like to search by?', ['ID', 'Email']));
$value = $this->ask("Please provide an $column to search for");
}
@ -68,7 +68,7 @@ class ResetPassword extends Command
try {
$user->update(['password' => Hash::make($password)]);
$this->info("User {$user->id} ({$user->email}) password update successful!");
return Command::SUCCESS;
return 0;
} catch (\Exception $e) {
$this->error('Unable to set the password!');
$this->line($e->getMessage());

View File

@ -42,18 +42,18 @@ class HandleInertiaRequests extends Middleware
*/
public function share(Request $request): array
{
$localeFields = ['locale_name', 'iso_code', 'name', 'localized_name'];
$localeFields = ['locale', 'iso_code', 'name', 'localized_name'];
$currentLocale = $request->session()->get('locale', null);
if (is_null($currentLocale)) {
$currentLocale = Language::where(['locale_name' => 'en', 'iso_code' => 'en_US'])->get($localeFields)[0]->toArray();
$currentLocale = Language::where(['locale' => 'en', 'iso_code' => 'en_US'])->get($localeFields)[0]->toArray();
$request->session()->put('locale', [
'locale_name' => $currentLocale['locale_name'],
'locale' => $currentLocale['locale'],
'iso_code' => $currentLocale['iso_code'],
'name' => $currentLocale['name'],
'localized_name' => $currentLocale['localized_name'],
]);
}
$localeFilePath = base_path("lang/{$currentLocale['locale_name']}.json");
$localeFilePath = base_path("lang/{$currentLocale['locale']}.json");
$notifications = [];
$notificationsCount = count($notifications);

View File

@ -1,51 +0,0 @@
<?php
namespace App\Models\Casts;
use Brick\Money\Money;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
class MoneyCastable implements CastsAttributes
{
/**
* Get the value from the database and modify it to casted type
* before returning.
*
* @package App\Models\Casts\MoneyCastable
* @since 1.0.0
*
* @param \Illuminate\Database\Eloquent\Model $model The Model that is being used
* @param string $key The attribute key
* @param mixed $value The value stored in the database
* @param array $attributes The array of model attributes
*
* @return \Brick\Money\Money
*/
public function get(Model $model, string $key, $value, array $attributes): Money
{
return Money::ofMinor($attributes['amount'], $attributes['currency']);
}
/**
* Store the data .
*
* @package App\Models\Casts\MoneyCastable
* @since 1.0.0
*
* @param \Illuminate\Database\Eloquent\Model $model The Model that is being used
* @param string $key The attribute key
* @param mixed $value The value stored in the database
* @param array $attributes The array of model attributes
*
* @return mixed
*/
public function set(Model $model, string $key, $value, array $attributes)
{
if (! $value instanceof Money) {
return $value;
}
return $value->getMinorAmount()->toInt();
}
}

View File

@ -7,20 +7,18 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Language extends Model
{
use HasFactory;
use Prunable;
use SoftDeletes;
/** @var string */
protected $table = 'languages';
/** @var array<int,string> */
protected $fillable = [
'locale_name',
'locale',
'iso_code',
'name',
'localized_name',

View File

@ -59,7 +59,6 @@
"spatie/laravel-sitemap": "", // generate site maps
"artesaos/seotools": "", // automatic SEO tools
"eumanito/php-capitalize-names": "", // Capitalize names with funky rules
"robinvdvleuten/ulid": "", // Universally Unique Lexicographically Sortable Identifier (ULID)
// Others/uncategorized
"appstract/laravel-opcache": "", // provides artisan commands to interact with opcache (not sure if site-specific)

View File

@ -32,7 +32,7 @@ class UserFactory extends Factory
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'timezone_name' => $this->faker->timezone(),
'language_id' => Language::all()->random()->id,
'timezone_name' => Language::all()->random()->id,
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];

View File

@ -15,7 +15,7 @@ return new class extends Migration
{
Schema::create('languages', function (Blueprint $table) {
$table->id();
$table->string('locale_name')->index();
$table->string('locale')->index();
$table->string('iso_code')->unique();
$table->string('name');
$table->string('localized_name');

View File

@ -1,24 +1,24 @@
<?php
// phpcs:ignore
/**
|--------------------------------------------------------------------------
| Global String Functions
|--------------------------------------------------------------------------
|
| This is a home for functions that don't belong to any one class and
| that should be available anywhere in the application.
|
*/
|--------------------------------------------------------------------------
| Global String Functions
|--------------------------------------------------------------------------
|
| This is a home for functions that don't belong to any one class and
| that should be available anywhere in the application.
|
*/
if (! function_exists('snake2Title')) {
/**
* Convert a snake case string to a title with spaces
* and every word capitalized.
*
* @param string $snakeSlug A snake case string, commonly a slug
*
* @since 1.0.0
*
* @param string $stakeSlug A snake case string, commonly a slug
*
* @return string
*/
function snake2Title(string $snakeSlug): string

View File

@ -34,10 +34,13 @@ body {
html, body {
transition-duration: 0.05s;
transition-property: background, color;
transition-timing-function: ease-in-out;
}
html, body {
transition-property: background, color;
}
button, a {
transition-property: all;
}

View File

@ -3,7 +3,7 @@
}
.form-label {
@apply uppercase font-semibold text-xs text-zinc-600 dark:text-zinc-200;
@apply uppercase font-semibold text-xs text-zinc-600 dark:text-zinc-300;
}
input.form-input[type="date"],
@ -67,5 +67,5 @@ input.form-input[type="url"]:disabled,
input.form-input[type="week"]:disabled,
textarea.form-input:disabled,
select.form-input:disabled {
@apply bg-neutral-400 opacity-75;
@apply bg-neutral-400 opacity-7;
}

View File

@ -1,5 +1,4 @@
<script setup>
// defines
defineProps({
message: String,
})