Skip to content

Commit

Permalink
Merge pull request #54 from barbosa89/feature/migrate-mix-to-vite
Browse files Browse the repository at this point in the history
Migrate Laravel Mix to Vite
  • Loading branch information
barbosa89 authored Nov 11, 2024
2 parents 6cb26bd + 73aaf9d commit 258de44
Show file tree
Hide file tree
Showing 836 changed files with 10,199 additions and 151,589 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
Expand Down
34 changes: 14 additions & 20 deletions app/Console/Commands/CreateRootUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,34 @@ public function __construct()
*/
public function handle()
{
$this->info('Important!' . PHP_EOL);
$this->info('If the supplied email exists in the database, then your password will be updated.' . PHP_EOL);
$this->info('Important!'.PHP_EOL);
$this->info('If the supplied email exists in the database, then your password will be updated.'.PHP_EOL);
$this->info('Requirements:');
$this->info('- Unique email');
$this->info('- Unique user with root role');
$this->info('- Maximum password length: 24 chars');
$this->info('- Minimum password length: 8 chars' . PHP_EOL);
$this->info('- Minimum password length: 8 chars'.PHP_EOL);

// Query existing root user
$user = User::whereHas('roles', function ($query) {
$user = User::whereHas('roles', function ($query): void {
$query->where('name', 'root');
})->first();

if (empty($user)) {
$email = $this->ask('Type your Root email: ');

if ($this->validEmail($email)) {
$user = new User();
$user = new User;
$user->email = $email;
} else {
$this->info('You cannot register the email as root user');

return;
}
} else {
$this->info("Existing root user: ");
$this->info('Existing root user: ');
$this->info("Name: {$user->name}");
$this->info("Email: {$user->email}" . PHP_EOL);
$this->info("Email: {$user->email}".PHP_EOL);
}

$password = $this->ask('Type your Root password: ');
Expand All @@ -80,7 +80,7 @@ public function handle()
$user->fill([
'name' => 'Root',
'email_verified_at' => now(),
'password' => bcrypt($password)
'password' => bcrypt($password),
]);

// If Root user was stored
Expand All @@ -93,24 +93,21 @@ public function handle()

// Output
$this->line('The Root user');
$this->line('Email: ' . $user->email);
$this->line('Password: ' . $password);
$this->line('Email: '.$user->email);
$this->line('Password: '.$password);
}

/**
* Validate root user
*
* @param string $email
* @return boolean
*/
public function validEmail(string $email): bool
{
$validator = Validator::make(
[
'email' => $email
'email' => $email,
],
[
'email' => 'required|email:rfc,dns,spoof,filter|unique:users,email'
'email' => 'required|email:rfc,dns,spoof,filter|unique:users,email',
]
);

Expand All @@ -123,18 +120,15 @@ public function validEmail(string $email): bool

/**
* Validate root password
*
* @param string $password
* @return boolean
*/
public function isInvalidPassword(string $password): bool
{
$validator = Validator::make(
[
'password' => $password
'password' => $password,
],
[
'password' => 'required|string|min:8|max:24'
'password' => 'required|string|min:8|max:24',
]
);

Expand Down
1 change: 0 additions & 1 deletion app/Console/Commands/PurgeInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Console\Commands;

use App\Models\Invoice;
use App\Models\User;
use Illuminate\Console\Command;

class PurgeInvoices extends Command
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/SaveTestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function handle()
'model_has_roles',
'role_has_permissions',
'rooms',
'users'
'users',
];

Artisan::call('iseed ' . implode(',', $tables) . ' --force');
Artisan::call('iseed '.implode(',', $tables).' --force');
}
}
7 changes: 4 additions & 3 deletions app/Console/Commands/SyncUserPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\LazyCollection;
use Spatie\Permission\Models\Permission;
Expand All @@ -22,12 +23,12 @@ class SyncUserPermissions extends Command

public function handle(): int
{
DB::transaction(function () {
DB::transaction(function (): void {
$permissions = Permission::all(['id', 'name', 'guard_name']);

LazyCollection::make(function () {
LazyCollection::make(function (): array|Collection {
return User::owner()->get(['id']);
})->each(function (User $user) use ($permissions) {
})->each(function (User $user) use ($permissions): void {
$user->syncPermissions($permissions);
});
});
Expand Down
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
1 change: 1 addition & 0 deletions app/Constants/Genders.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Genders
{
public const MALE = 'm';

public const FEMALE = 'f';

public const DESCRIPTION = [
Expand Down
5 changes: 5 additions & 0 deletions app/Constants/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
class Roles implements Arrayable
{
public const ROOT = 'root';

public const MANAGER = 'manager';

public const ADMIN = 'admin';

public const RECEPTIONIST = 'receptionist';

public const ACCOUNTANT = 'accountant';

public const CASHIER = 'cashier';

public function toArray(): array
Expand Down
4 changes: 0 additions & 4 deletions app/Contracts/CompanyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@

interface CompanyRepository extends Repository
{
/**
* @param string $query
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function search(string $query): LengthAwarePaginator;
}
4 changes: 0 additions & 4 deletions app/Contracts/GuestRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@

interface GuestRepository extends Repository
{
/**
* @param string $query
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function search(string $query): LengthAwarePaginator;
}
26 changes: 1 addition & 25 deletions app/Contracts/NestedRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Contracts;

use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;

/**
* Standard repository for nested resources
Expand All @@ -13,55 +13,31 @@ interface NestedRepository
{
/**
* Get paginated model collection
*
* @param int $parent
* @param int $perPage
* @param array $filters
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function paginate(int $parent, int $perPage = 15, array $filters = []): LengthAwarePaginator;


/**
* Get complete model collection
*
* @param int $parent
* @param array $filters
* @return \Illuminate\Support\Collection
*/
public function all(int $parent, array $filters = []): Collection;

/**
* Get model
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Model
*/
public function find(int $id): Model;

/**
* Create a new model
*
* @param int $parent
* @param array $data
* @return \Illuminate\Database\Eloquent\Model
*/
public function create(int $parent, array $data): Model;

/**
* Update model
*
* @param int $id
* @param array $data
* @return \Illuminate\Database\Eloquent\Model
*/
public function update(int $id, array $data): Model;

/**
* Destroy model
*
* @param int $id
* @return bool
*/
public function destroy(int $id): bool;
}
20 changes: 0 additions & 20 deletions app/Contracts/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,31 @@ interface Repository
{
/**
* Get paginated model collection
*
* @param int $perPage
* @param array $filters
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function paginate(int $perPage = 15, array $filters = []): LengthAwarePaginator;

/**
* Get complete model collection
*
* @param array $filters
* @return \Illuminate\Support\Collection
*/
public function all(array $filters = []): Collection;

/**
* Get model
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Model
*/
public function find(int $id): Model;

/**
* Create a new model
*
* @param array $data
* @return \Illuminate\Database\Eloquent\Model
*/
public function create(array $data): Model;

/**
* Update model
*
* @param int $id
* @param array $data
* @return \Illuminate\Database\Eloquent\Model
*/
public function update(int $id, array $data): Model;

/**
* Destroy model
*
* @param int $id
* @return bool
*/
public function destroy(int $id): bool;
}
9 changes: 0 additions & 9 deletions app/Contracts/RoomRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@

interface RoomRepository extends NestedRepository
{
/**
* @param string $query
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function search(string $query): LengthAwarePaginator;


/**
* Change model status
*
* @param integer $id
* @param string $status
* @return Model
*/
public function toggle(int $id, string $status): Model;
}
19 changes: 2 additions & 17 deletions app/Contracts/VoucherRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,24 @@

namespace App\Contracts;

use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;

interface VoucherRepository extends NestedRepository
{
/**
* @param string $query
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function search(string $query): LengthAwarePaginator;

/**
* Get model collection
*
* @return \Illuminate\Support\Collection
*/
public function list(): Collection;

/**
* Get model
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Model
*/
public function first(int $id): Model;

/**
* @param integer $hotelId
* @param \Illuminate\Support\Carbon $startDate
* @param \Illuminate\Support\Carbon $endDate
* @return \Illuminate\Support\Collection
*/
public function queryGuestChecks(int $hotelId, Carbon $startDate, Carbon $endDate): Collection;
}
Loading

0 comments on commit 258de44

Please sign in to comment.