#90 - user profile #125

Merged
Baakoma merged 19 commits from #90-user-profile into main 2022-04-14 11:58:45 +02:00
6 changed files with 68 additions and 48 deletions
Showing only changes of commit 5356b0fc8c - Show all commits

View File

@@ -21,7 +21,7 @@ class ExceptionHandler extends Handler
{
$response = parent::render($request, $e);
if (! app()->environment("production")) {
if (!app()->environment("production")) {
return $response;
}

View File

@@ -0,0 +1,30 @@
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
<?php
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
declare(strict_types=1);
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
namespace Toby\Infrastructure\Console\Commands;
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
use Illuminate\Console\Command;
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
use Toby\Eloquent\Models\User;
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
class MoveUserDataToProfile extends Command
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
{
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
protected $signature = "toby:move-user-data-to-profile";
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
protected $description = "Move user data to their profiles";
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
public function handle(): void
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
{
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
$users = User::all();
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
/** @var User $user */
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
foreach ($users as $user) {
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
$user->profile()->updateOrCreate(["user_id" => $user->id], [
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
"first_name" => $user->first_name,
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
"last_name" => $user->last_name,
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
"position" => $user->position,
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
"employment_form" => $user->employment_form,
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
"employment_date" => $user->employment_date,
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
]);
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
}
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
}
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?
}
krzysztofrewak commented 2022-04-14 11:19:38 +02:00 (Migrated from github.com)
Review
Do we need this docblock with these here https://github.com/illuminate/collections/blob/master/Collection.php#L60 ?

View File

@@ -21,7 +21,7 @@ class DashboardController extends Controller
public function __invoke(
Request $request,
YearPeriodRetriever $yearPeriodRetriever,
UserVacationStatsRetriever $vacationStatsRetriever
UserVacationStatsRetriever $vacationStatsRetriever,
): Response {
$user = $request->user();
$now = Carbon::now();

View File

@@ -16,8 +16,7 @@ class HandleInertiaRequests extends Middleware
{
public function __construct(
protected YearPeriodRetriever $yearPeriodRetriever,
krzysztofrewak commented 2022-04-14 11:20:20 +02:00 (Migrated from github.com)
Review
        return fn(): array => $request->user() ? $this->yearPeriodRetriever->links() : [];
```suggestion return fn(): array => $request->user() ? $this->yearPeriodRetriever->links() : []; ```
krzysztofrewak commented 2022-04-14 11:20:45 +02:00 (Migrated from github.com)
Review
        return fn(): ?int => $user && $user->can("listAll", VacationRequest::class)
```suggestion return fn(): ?int => $user && $user->can("listAll", VacationRequest::class) ```
) {
}
) {}
public function share(Request $request): array
{

View File

@@ -4,11 +4,14 @@ declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
public function up(): void
{
Artisan::call("toby:move-user-data-to-profile");
Schema::table("users", function (Blueprint $table): void {
$table->dropColumn("first_name");
$table->dropColumn("last_name");

View File

@@ -30,87 +30,75 @@ class DemoSeeder extends Seeder
public function run(): void
{
$user = User::factory([
"first_name" => "Jan",
"last_name" => "Kowalski",
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "programista",
"role" => Role::Administrator,
"employment_date" => Carbon::createFromDate(2021, 12, 31),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Jan",
"last_name" => "Kowalski",
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "programista",
"employment_date" => Carbon::createFromDate(2021, 12, 31),
])
->create();
User::factory([
"first_name" => "Anna",
"last_name" => "Nowak",
"email" => "anna.nowak@example.com",
"employment_form" => EmploymentForm::CommissionContract,
"position" => "tester",
"role" => Role::Employee,
"employment_date" => Carbon::createFromDate(2021, 5, 10),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Anna",
"last_name" => "Nowak",
"employment_form" => EmploymentForm::CommissionContract,
"position" => "tester",
"employment_date" => Carbon::createFromDate(2021, 5, 10),
])
->create();
User::factory([
"first_name" => "Tola",
"last_name" => "Sawicka",
"email" => "tola.sawicka@example.com",
"employment_form" => EmploymentForm::B2bContract,
"position" => "programista",
"role" => Role::Employee,
"employment_date" => Carbon::createFromDate(2021, 1, 4),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Tola",
"last_name" => "Sawicka",
"employment_form" => EmploymentForm::B2bContract,
"position" => "programista",
"employment_date" => Carbon::createFromDate(2021, 1, 4),
])
->create();
$technicalApprover = User::factory([
"first_name" => "Maciej",
"last_name" => "Ziółkowski",
"email" => "maciej.ziolkowski@example.com",
"employment_form" => EmploymentForm::BoardMemberContract,
"position" => "programista",
"role" => Role::TechnicalApprover,
"employment_date" => Carbon::createFromDate(2021, 1, 4),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Maciej",
"last_name" => "Ziółkowski",
"employment_form" => EmploymentForm::BoardMemberContract,
"position" => "programista",
"employment_date" => Carbon::createFromDate(2021, 1, 4),
])
->create();
$administrativeApprover = User::factory([
"first_name" => "Katarzyna",
"last_name" => "Zając",
"email" => "katarzyna.zajac@example.com",
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "dyrektor",
"role" => Role::AdministrativeApprover,
"employment_date" => Carbon::createFromDate(2021, 1, 4),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Katarzyna",
"last_name" => "Zając",
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "dyrektor",
"employment_date" => Carbon::createFromDate(2021, 1, 4),
])
->create();
User::factory([
"first_name" => "Miłosz",
"last_name" => "Borowski",
"email" => "milosz.borowski@example.com",
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "administrator",
"role" => Role::Administrator,
"employment_date" => Carbon::createFromDate(2021, 1, 4),
"remember_token" => Str::random(10),
])
->hasProfile([
"first_name" => "Miłosz",
"last_name" => "Borowski",
"employment_form" => EmploymentForm::EmploymentContract,
"position" => "administrator",
"employment_date" => Carbon::createFromDate(2021, 1, 4),
])
->create();
$users = User::all();
@@ -130,7 +118,7 @@ class DemoSeeder extends Seeder
->afterCreating(function (YearPeriod $yearPeriod) use ($users): void {
foreach ($users as $user) {
VacationLimit::factory([
"days" => $user->profile->employment_form === EmploymentForm::EmploymentContract ? 26 : null,
"days" => $user->employment_form === EmploymentForm::EmploymentContract ? 26 : null,
])
->for($yearPeriod)
->for($user)
@@ -329,4 +317,4 @@ class DemoSeeder extends Seeder
$vacationRequestRejected->state = new Rejected($vacationRequestRejected);
$vacationRequestRejected->save();
}
}
}