- append more informations from api

This commit is contained in:
Kamil Niemczycki 2023-07-04 01:12:05 +02:00
parent ac90d45519
commit 99f0bafe93
Signed by: kamilniemczycki
GPG Key ID: 04D4E2012F969213
8 changed files with 78 additions and 3 deletions

View File

@ -27,6 +27,8 @@ class CVInfo extends Command
$this->line('Phone: '. $cv->formattedPhoneNumber .', '. $cv->PhoneNumber); $this->line('Phone: '. $cv->formattedPhoneNumber .', '. $cv->PhoneNumber);
$this->line('Locations: '. implode(' / ', $cv->locations)); $this->line('Locations: '. implode(' / ', $cv->locations));
$this->line('Views: '. $cv->views); $this->line('Views: '. $cv->views);
$this->line('Mission: '. (is_null($mission = $cv->mission) ? 'domyślne' : $mission));
$this->line('Rodo: '. (is_null($rodo = $cv->rodo) ? 'domyślne' : $rodo));
$this->line(''); $this->line('');
$this->line('Showed list:'); $this->line('Showed list:');

View File

@ -15,7 +15,9 @@ class CreateCV extends Command
{recipient : Company} {recipient : Company}
{email : E-mail address} {email : E-mail address}
{phone : Phone number - with spaces} {phone : Phone number - with spaces}
{location?* : List of locations}'; {location?* : List of locations}
{--mission= : Description of mission}
{--rodo= : Description of rodo}';
protected $description = 'Create CV'; protected $description = 'Create CV';
@ -25,6 +27,8 @@ class CreateCV extends Command
$email = $this->argument('email'); $email = $this->argument('email');
$phone = $this->argument('phone'); $phone = $this->argument('phone');
$locations = $this->argument('location'); $locations = $this->argument('location');
$mission = $this->option('mission');
$rodo = $this->option('rodo');
CV::query() CV::query()
->create([ ->create([
@ -33,6 +37,8 @@ class CreateCV extends Command
'email' => $email, 'email' => $email,
'phone_number' => $phone, 'phone_number' => $phone,
'locations' => $locations, 'locations' => $locations,
'mission' => $mission,
'rodo' => $rodo,
]); ]);
$this->info('Created!'); $this->info('Created!');

View File

@ -26,7 +26,7 @@ class ListCV extends Command
$this->line('Company: '. $resource->recipient); $this->line('Company: '. $resource->recipient);
$this->line('Phone: '. $resource->formattedPhoneNumber .', '. $resource->PhoneNumber); $this->line('Phone: '. $resource->formattedPhoneNumber .', '. $resource->PhoneNumber);
$this->line('Locations: '. implode(' / ', $resource->locations)); $this->line('Locations: '. implode(' / ', $resource->locations));
$this->line('Views: '. $resource->views); $this->line('Rodo: '. $resource->rodo);
$this->line(''); $this->line('');
} }

View File

@ -15,7 +15,9 @@ class UpdateCV extends Command
{--phone= : Phone number} {--phone= : Phone number}
{--begin-location : Add begin} {--begin-location : Add begin}
{--add-location=* : Add locations} {--add-location=* : Add locations}
{--remove-location=* : Remove lcoations}'; {--remove-location=* : Remove lcoations}
{--mission= : Set new text value}
{--rodo= : Set new text value}';
protected $description = 'Update CV element'; protected $description = 'Update CV element';
@ -58,6 +60,13 @@ class UpdateCV extends Command
$cv->locations = $locations; $cv->locations = $locations;
} }
if ($mission = $this->option('mission')) {
$cv->mission = $mission === 'null' ? null : $mission;
}
if ($rodo = $this->option('rodo')) {
$cv->rodo = $rodo === 'null' ? null : $rodo;
}
$cv->save(); $cv->save();
$this->info('Updated!'); $this->info('Updated!');

View File

@ -19,6 +19,14 @@ class CVResource extends JsonResource
'formattedPhoneNumber' => $this->formattedPhoneNumber, 'formattedPhoneNumber' => $this->formattedPhoneNumber,
'phone' => new PhoneResource($this->resource), 'phone' => new PhoneResource($this->resource),
'locations' => $this->locations, 'locations' => $this->locations,
'mission' => $this->when(
!is_null($this->mission),
fn (): array => explode(PHP_EOL, $this->mission, 5)
),
'rodo' => $this->when(
!is_null($this->rodo),
$this->rodo
),
]; ];
} }
} }

View File

@ -16,6 +16,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property string $email * @property string $email
* @property string $phoneNumber * @property string $phoneNumber
* @property array $locations * @property array $locations
* @property string|null $mission
* @property string|null $rodo
* @property int $views * @property int $views
*/ */
class CV extends Model class CV extends Model

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('cvs', function (Blueprint $table) {
$table->text('mission')->nullable();
});
}
public function down(): void
{
Schema::table('cvs', function (Blueprint $table) {
$table->dropColumn('mission');
});
}
};

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('cvs', function (Blueprint $table) {
$table->text('rodo')->nullable();
});
}
public function down(): void
{
Schema::table('cvs', function (Blueprint $table) {
$table->dropColumn('rodo');
});
}
};