- wip
This commit is contained in:
parent
2cbcaee7f5
commit
08133d0b05
40
app/Console/Commands/CreateCV.php
Normal file
40
app/Console/Commands/CreateCV.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\CV;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||||
|
|
||||||
|
class CreateCV extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'cv:create
|
||||||
|
{recipient : Company}
|
||||||
|
{email : E-mail address}
|
||||||
|
{phone : Phone number - with spaces}
|
||||||
|
{location?* : List of locations}';
|
||||||
|
|
||||||
|
protected $description = 'Create CV';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$recipient = $this->argument('recipient');
|
||||||
|
$email = $this->argument('email');
|
||||||
|
$phone = $this->argument('phone');
|
||||||
|
$locations = $this->argument('location');
|
||||||
|
|
||||||
|
CV::query()
|
||||||
|
->create([
|
||||||
|
// 'slug' => Str::ra,
|
||||||
|
'recipient' => $recipient,
|
||||||
|
'email' => $email,
|
||||||
|
'phone-number' => $phone,
|
||||||
|
'locations' => $locations,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return CommandAlias::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
28
app/Models/CV.php
Normal file
28
app/Models/CV.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $recipient
|
||||||
|
* @property string $email
|
||||||
|
* @property string $phoneNumber
|
||||||
|
* @property array $locations
|
||||||
|
* @property int $views
|
||||||
|
*/
|
||||||
|
class CV extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'cvs';
|
||||||
|
protected $guarded = [];
|
||||||
|
protected $casts = [
|
||||||
|
'locations' => 'array',
|
||||||
|
'views' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
28
database/migrations/2023_06_15_220540_create_cvs_table.php
Normal file
28
database/migrations/2023_06_15_220540_create_cvs_table.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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::create('cvs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('recipient', 255);
|
||||||
|
$table->string('email', 255);
|
||||||
|
$table->string('phone-number', 15);
|
||||||
|
$table->json('locations');
|
||||||
|
$table->integer('views')->nullable()->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cvs');
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user