- add send CV status
This commit is contained in:
parent
6a033d108c
commit
2a2869e2c6
@ -56,6 +56,17 @@ class CVController extends Controller
|
|||||||
->with('success', 'Utworzono nowe CV dla firmy ' . $request->get('recipient'));
|
->with('success', 'Utworzono nowe CV dla firmy ' . $request->get('recipient'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateSendStatus(CV $cv): RedirectResponse
|
||||||
|
{
|
||||||
|
$cv->update([
|
||||||
|
'sended' => true,
|
||||||
|
'sended_timestamp' => now()
|
||||||
|
]);
|
||||||
|
return redirect()
|
||||||
|
->route('admin.cv.show', ['cv' => $cv])
|
||||||
|
->with('success', 'Status wysłania ustawiono jako "wysłano".');
|
||||||
|
}
|
||||||
|
|
||||||
public function edit(CV $cv): InertiaResponse
|
public function edit(CV $cv): InertiaResponse
|
||||||
{
|
{
|
||||||
return inertia('CV/Edit', [
|
return inertia('CV/Edit', [
|
||||||
@ -65,16 +76,30 @@ class CVController extends Controller
|
|||||||
|
|
||||||
public function update(CVRequest $request, CV $cv): RedirectResponse
|
public function update(CVRequest $request, CV $cv): RedirectResponse
|
||||||
{
|
{
|
||||||
$cv->update([
|
$toUpdate = [
|
||||||
'recipient' => $request->get('recipient'),
|
'recipient' => $request->get('recipient'),
|
||||||
'email' => $request->get('email'),
|
'email' => $request->get('email'),
|
||||||
'phone_number' => $request->get('phone_number'),
|
'phone_number' => $request->get('phone_number'),
|
||||||
'locations' => ($locations = $request->get('locations')) === [''] ? [] : $locations,
|
'locations' => ($locations = $request->get('locations')) === [''] ? [] : $locations,
|
||||||
'mission' => ($mission = $request->get('mission')) === [''] ? [] : $mission,
|
'mission' => ($mission = $request->get('mission')) === [''] ? [] : $mission,
|
||||||
'rodo' => ($rodo =$request->get('rodo')) === '' ? null : $rodo,
|
'rodo' => ($rodo =$request->get('rodo')) === '' ? null : $rodo,
|
||||||
'position' => $request->get('position'),
|
'position' => $request->get('position'),
|
||||||
'notes' => $request->get('notes'),
|
'notes' => $request->get('notes'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($cv->sended && ! $request->boolean('sended')) {
|
||||||
|
$toUpdate = array_merge($toUpdate, [
|
||||||
|
'sended' => false,
|
||||||
|
'sended_timestamp' => null,
|
||||||
]);
|
]);
|
||||||
|
} else if (! $cv->sended && $request->boolean('sended')) {
|
||||||
|
$toUpdate = array_merge($toUpdate, [
|
||||||
|
'sended' => true,
|
||||||
|
'sended_timestamp' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cv->update($toUpdate);
|
||||||
return redirect()
|
return redirect()
|
||||||
->back()
|
->back()
|
||||||
->with('success', 'Zaktualizowano CV dla firmy ' . $request->get('recipient'));
|
->with('success', 'Zaktualizowano CV dla firmy ' . $request->get('recipient'));
|
||||||
|
@ -19,6 +19,19 @@ class CVRequest extends FormRequest
|
|||||||
'rodo' => 'nullable|string',
|
'rodo' => 'nullable|string',
|
||||||
'position' => 'nullable|string',
|
'position' => 'nullable|string',
|
||||||
'notes' => 'nullable|string',
|
'notes' => 'nullable|string',
|
||||||
|
'sended' => 'nullable|boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'sended' => $this->toBoolean($this->sended),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function toBoolean($booleable): bool
|
||||||
|
{
|
||||||
|
return filter_var($booleable, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class ProjectRequest extends FormRequest
|
|||||||
|
|
||||||
'project_url' => 'nullable|string',
|
'project_url' => 'nullable|string',
|
||||||
'project_version' => 'nullable|string',
|
'project_version' => 'nullable|string',
|
||||||
'description' => 'nullable|string',
|
'description' => 'required|string|min:3',
|
||||||
'visible' => 'required|boolean'
|
'visible' => 'required|boolean'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,10 @@ class FullCVResource extends JsonResource
|
|||||||
'locations' => $this->locations,
|
'locations' => $this->locations,
|
||||||
'views' => $this->resource->info()->select('id')->get()->count(),
|
'views' => $this->resource->info()->select('id')->get()->count(),
|
||||||
'registeredViews' => $this->views,
|
'registeredViews' => $this->views,
|
||||||
|
'sended' => [
|
||||||
|
'status' => $this->sended,
|
||||||
|
'datetime' => $this->sended_timestamp?->format('d-m-Y H:i:s'),
|
||||||
|
],
|
||||||
'position' => $this->position,
|
'position' => $this->position,
|
||||||
'mission' => explode(PHP_EOL, $this->mission ?? '', 5),
|
'mission' => explode(PHP_EOL, $this->mission ?? '', 5),
|
||||||
'rodo' => $this->rodo,
|
'rodo' => $this->rodo,
|
||||||
|
@ -21,6 +21,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* @property string|null $position
|
* @property string|null $position
|
||||||
* @property string|null $notes
|
* @property string|null $notes
|
||||||
* @property int $views
|
* @property int $views
|
||||||
|
* @property bool $sended
|
||||||
*/
|
*/
|
||||||
class CV extends Model
|
class CV extends Model
|
||||||
{
|
{
|
||||||
@ -31,6 +32,8 @@ class CV extends Model
|
|||||||
protected $casts = [
|
protected $casts = [
|
||||||
'locations' => 'array',
|
'locations' => 'array',
|
||||||
'views' => 'integer',
|
'views' => 'integer',
|
||||||
|
'sended' => 'boolean',
|
||||||
|
'sended_timestamp' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function phoneNumber(): Attribute
|
protected function phoneNumber(): Attribute
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
<?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->boolean('sended')->nullable()->default(false)->after('views');
|
||||||
|
$table->timestamp('sended_timestamp')->nullable()->after('sended');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cvs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('sended');
|
||||||
|
$table->dropColumn('sended_timestamp');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -40,6 +40,7 @@ const form = useForm({
|
|||||||
rodo: props.cv.rodo,
|
rodo: props.cv.rodo,
|
||||||
position: props.cv.position,
|
position: props.cv.position,
|
||||||
notes: props.cv.notes,
|
notes: props.cv.notes,
|
||||||
|
sended: props.cv.sended.status,
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateCV() {
|
function updateCV() {
|
||||||
@ -128,6 +129,12 @@ function updateCV() {
|
|||||||
v-model="form.rodo"
|
v-model="form.rodo"
|
||||||
:error="form.errors.rodo"
|
:error="form.errors.rodo"
|
||||||
/>
|
/>
|
||||||
|
<Input
|
||||||
|
id="sended"
|
||||||
|
label="Wysłany"
|
||||||
|
type="checkbox"
|
||||||
|
v-model="form.sended"
|
||||||
|
/>
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 sm:gap-2 items-center">
|
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 sm:gap-2 items-center">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
as="button"
|
as="button"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { router } from '@inertiajs/inertia';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
cv: {
|
cv: {
|
||||||
@ -21,6 +22,15 @@ const cvNotes = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<InertiaHead title="Szczegóły CV" />
|
<InertiaHead title="Szczegóły CV" />
|
||||||
|
<div class="px-3 py-2">
|
||||||
|
<InertiaLink
|
||||||
|
v-if="!cv.sended.status"
|
||||||
|
as="button"
|
||||||
|
method="post"
|
||||||
|
:href="`/dashboard/cv/${cv.token}/sended`"
|
||||||
|
class="w-full px-0.5 py-1 rounded-lg bg-[#436da7] border-4 border-[#436da7] text-white text-lg hover:bg-transparent hover:text-[#436da7]"
|
||||||
|
title="Ustaw jako wysłane">Ustaw jako wysłane do odbiorcy.</InertiaLink>
|
||||||
|
</div>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<header class="flex justify-between items-center pb-4">
|
<header class="flex justify-between items-center pb-4">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
@ -52,6 +62,9 @@ const cvNotes = computed(() => {
|
|||||||
><FontAwesomeIcon :icon="['fas', 'trash']" /><span class="hidden sm:inline-block">Usuń</span></InertiaLink>
|
><FontAwesomeIcon :icon="['fas', 'trash']" /><span class="hidden sm:inline-block">Usuń</span></InertiaLink>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<div v-if="cv.sended.status" class="max-w-screen-lg my-2 lg:mx-auto px-2 py-3 rounded-md bg-yellow-100 text-yellow-600 text-center">
|
||||||
|
CV jest oznaczone jako wysłane - {{ cv.sended.datetime }}
|
||||||
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<header>
|
<header>
|
||||||
<h2 class="text-2xl font-roboto font-light pb-3">Podstawowe informacje</h2>
|
<h2 class="text-2xl font-roboto font-light pb-3">Podstawowe informacje</h2>
|
||||||
|
@ -33,7 +33,7 @@ defineProps({
|
|||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div v-if="messages?.info" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-yellow-100 text-yellow-600 text-center">
|
<div v-if="messages?.info" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-yellow-100 text-yellow-600 text-center">
|
||||||
{{ messages.info }}
|
{{ messages.info }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="messages?.error" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-red-100 text-red-600 text-center">
|
<div v-if="messages?.error" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-red-100 text-red-600 text-center">
|
||||||
|
@ -22,6 +22,8 @@ Route::name('admin.')->group(function () {
|
|||||||
->name('store');
|
->name('store');
|
||||||
Route::get('{cv}', 'CVController@show')
|
Route::get('{cv}', 'CVController@show')
|
||||||
->name('show');
|
->name('show');
|
||||||
|
Route::post('{cv}/sended', 'CVController@updateSendStatus')
|
||||||
|
->name('sended');
|
||||||
Route::post('', 'CVController@store')
|
Route::post('', 'CVController@store')
|
||||||
->name('store');
|
->name('store');
|
||||||
Route::get('{cv}/edit', 'CVController@edit')
|
Route::get('{cv}/edit', 'CVController@edit')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user