Vacancy entity

This commit is contained in:
Toy Rik 2026-01-23 13:03:38 +03:00
parent d85600ec18
commit d2d9f75235
32 changed files with 1580 additions and 391 deletions

View File

@ -22,6 +22,7 @@ services:
volumes:
- ./src:/app
working_dir: /app
restart: unless-stopped
networks:
back_net:
aliases:

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
abstract class Controller

View File

@ -13,7 +13,7 @@ class BaseModel extends Model
use HasUuids;
use HasFactory;
protected static function boot()
protected static function boot()
{
parent::boot();
}
@ -27,4 +27,4 @@ class BaseModel extends Model
{
return 'string';
}
}
}

View File

@ -1,10 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Support\Carbon;
/**
* @property string $uuid
* @property string $title
* @property string $description
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Carbon $deleted_at
*/
class Vacancy extends BaseModel
{
protected $fillable = [
'title',
'description',
];
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use Illuminate\Support\ServiceProvider;

View File

@ -1,13 +1,15 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
web: __DIR__ . '/../routes/web.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
App\Providers\AppServiceProvider::class,
];

View File

@ -17,7 +17,8 @@
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.3"
"pestphp/pest": "^4.3",
"pestphp/pest-plugin-laravel": "^4.0"
},
"autoload": {
"psr-4": {
@ -44,10 +45,6 @@
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
@ -65,6 +62,23 @@
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
],
"pint-test": [
"@php vendor/bin/pint --test -vvv"
],
"pint-fix": [
"@php vendor/bin/pint --repair"
],
"test": [
"@php artisan optimize:clear",
"@php vendor/bin/pest"
],
"checkit": [
"@pint-test",
"@test"
],
"ci": [
"@checkit"
]
},
"extra": {

1661
src/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Str;
return [
@ -112,6 +114,6 @@ return [
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-cache-'),
];

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Str;
return [
@ -148,7 +150,7 @@ return [
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*
@ -41,7 +43,7 @@ return [
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
@ -89,7 +91,7 @@ return [
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
/*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Str;
return [
@ -129,7 +131,7 @@ return [
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
Str::slug((string) env('APP_NAME', 'laravel')) . '-session'
),
/*

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Vacancy>
*/
class VacancyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('vacancies', function (Blueprint $table) {
$table->uuid()->primary();
$table->string('title');
$table->text('description');
$table->string('status');
$table->boolean('is_favorite')->default(false);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vacancies');
}
};

View File

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use App\Models\Vacancy;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class VacancySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Vacancy::factory(10)->create();
}
}

10
src/pint.json Normal file
View File

@ -0,0 +1,10 @@
{
"preset": "psr12",
"exclude": [
"database"
],
"rules": {
"declare_strict_types": true,
"concat_space": {"spacing": "one"}
}
}

View File

@ -1,20 +1,22 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';
$app->handleRequest(Request::capture());

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
Route::get('/', function () {

View File

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\App;
trait CreateApplication
{
public function createApplication(): Application
{
$app = require Application::inferBasePath() . '/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
if (App::environment() !== 'testing') {
dump('You are not in a test environment!');
dump('Run "php artisan optimize:clear" before tests');
dd('and "php artizan optimize" after if you are in production');
}
return $app;
}
}

View File

@ -1,19 +1,9 @@
<?php
namespace Tests\Feature;
declare(strict_types=1);
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
test('the application runs', function () {
$response = $this->get('/up');
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
$response->assertStatus(200);
});

49
src/tests/Pest.php Normal file
View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "pest()" function to bind a different classes or traits.
|
*/
pest()->extend(Tests\TestCase::class)
// ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
expect()->extend('toBeOne', function () {
return $this->toBe(1);
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
function something()
{
// ..
}

View File

@ -1,10 +1,12 @@
<?php
declare(strict_types=1);
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
use CreateApplication;
}

View File

@ -1,16 +1,7 @@
<?php
namespace Tests\Unit;
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
test('that true is true', function () {
expect(true)->toBeTrue();
});