- add position

This commit is contained in:
Kamil Niemczycki 2023-07-04 01:25:02 +02:00
parent 99f0bafe93
commit 996b1b4faf
Signed by: kamilniemczycki
GPG Key ID: 04D4E2012F969213
5 changed files with 38 additions and 2 deletions

View File

@ -17,7 +17,8 @@ class CreateCV extends Command
{phone : Phone number - with spaces} {phone : Phone number - with spaces}
{location?* : List of locations} {location?* : List of locations}
{--mission= : Description of mission} {--mission= : Description of mission}
{--rodo= : Description of rodo}'; {--rodo= : Description of rodo}
{--position= : Set position value}';
protected $description = 'Create CV'; protected $description = 'Create CV';
@ -29,6 +30,7 @@ class CreateCV extends Command
$locations = $this->argument('location'); $locations = $this->argument('location');
$mission = $this->option('mission'); $mission = $this->option('mission');
$rodo = $this->option('rodo'); $rodo = $this->option('rodo');
$position = $this->option('position');
CV::query() CV::query()
->create([ ->create([
@ -39,6 +41,7 @@ class CreateCV extends Command
'locations' => $locations, 'locations' => $locations,
'mission' => $mission, 'mission' => $mission,
'rodo' => $rodo, 'rodo' => $rodo,
'position' => $position,
]); ]);
$this->info('Created!'); $this->info('Created!');

View File

@ -17,7 +17,8 @@ class UpdateCV extends Command
{--add-location=* : Add locations} {--add-location=* : Add locations}
{--remove-location=* : Remove lcoations} {--remove-location=* : Remove lcoations}
{--mission= : Set new text value} {--mission= : Set new text value}
{--rodo= : Set new text value}'; {--rodo= : Set new text value}
{--position= : Set position value}';
protected $description = 'Update CV element'; protected $description = 'Update CV element';
@ -66,6 +67,9 @@ class UpdateCV extends Command
if ($rodo = $this->option('rodo')) { if ($rodo = $this->option('rodo')) {
$cv->rodo = $rodo === 'null' ? null : $rodo; $cv->rodo = $rodo === 'null' ? null : $rodo;
} }
if ($position = $this->option('position')) {
$cv->position = $position === 'null' ? null : $position;
}
$cv->save(); $cv->save();

View File

@ -27,6 +27,10 @@ class CVResource extends JsonResource
!is_null($this->rodo), !is_null($this->rodo),
$this->rodo $this->rodo
), ),
'position' => $this->when(
!is_null($this->position),
$this->position
),
]; ];
} }
} }

View File

@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property array $locations * @property array $locations
* @property string|null $mission * @property string|null $mission
* @property string|null $rodo * @property string|null $rodo
* @property string|null $position
* @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->string('position', 255)->nullable();
});
}
public function down(): void
{
Schema::table('cvs', function (Blueprint $table) {
$table->dropColumn('position');
});
}
};