-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddbb902
commit f96fe2e
Showing
13 changed files
with
289 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\UpdateContactInfoRequest; | ||
use App\Models\ContactInfo; | ||
use Illuminate\Http\RedirectResponse; | ||
use Inertia\Response; | ||
|
||
class ContactInfoController extends Controller | ||
{ | ||
public function edit(): Response | ||
{ | ||
return inertia("Dashboard/ContactInfo", [ | ||
"contactInfo" => ContactInfo::query()->first(), | ||
]); | ||
} | ||
|
||
public function update(UpdateContactInfoRequest $request): RedirectResponse | ||
{ | ||
ContactInfo::query()->first()->update($request->validated()); | ||
|
||
return redirect()->back() | ||
->with("success", "Zaktualizowano formy kontaktu"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class UpdateContactInfoRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"email" => ["required", "email", "max:255"], | ||
"github_handle" => ["nullable", "url"], | ||
"alternative_channel" => ["nullable", "url"], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Concerns\HasUlids; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @property string $id | ||
* @property string $email | ||
* @property string $github_handle | ||
* @property string $alternative_channel | ||
* @property Carbon $created_at | ||
* @property Carbon $updated_at | ||
*/ | ||
class ContactInfo extends Model | ||
{ | ||
use HasFactory; | ||
use HasUlids; | ||
|
||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\ContactInfo; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends Factory<ContactInfo> | ||
*/ | ||
class ContactInfoFactory extends Factory | ||
{ | ||
public function definition(): array | ||
{ | ||
return [ | ||
"email" => fake()->unique()->email(), | ||
"github_handle" => fake()->optional()->url(), | ||
"alternative_channel" => fake()->optional()->url(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
database/migrations/2023_09_23_135710_create_contact_infos_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?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("contact_infos", function (Blueprint $table): void { | ||
$table->ulid("id")->primary(); | ||
$table->string("email"); | ||
$table->string("github_handle")->nullable(); | ||
$table->string("alternative_channel")->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists("contact_infos"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<script setup> | ||
import DashboardLayout from '@/Layouts/DashboardLayout.vue' | ||
import Section from '@/Shared/Components/Section.vue' | ||
import SubmitButton from '@/Shared/Components/Buttons/SubmitButton.vue' | ||
import FormGroup from '@/Shared/Forms/FormGroup.vue' | ||
import FormLabel from '@/Shared/Forms/FormLabel.vue' | ||
import TextInput from '@/Shared/Forms/TextInput.vue' | ||
import SecondaryButton from '@/Shared/Components/Buttons/SecondaryButton.vue' | ||
import { useForm } from '@inertiajs/inertia-vue3' | ||
import FormError from '@/Shared/Forms/FormError.vue' | ||
const props = defineProps({ | ||
contactInfo: Object, | ||
}) | ||
const form = useForm({ | ||
email: props.contactInfo.email, | ||
github_handle: props.contactInfo.github_handle, | ||
alternative_channel: props.contactInfo.alternative_channel, | ||
}) | ||
function updateContact() { | ||
form.patch(`/dashboard/contact-info`) | ||
} | ||
</script> | ||
|
||
<template> | ||
<DashboardLayout> | ||
<h3 class="text-base font-semibold leading-6 text-gray-900"> | ||
Edycja form kontaktu | ||
</h3> | ||
<form @submit.prevent="updateContact"> | ||
<Section class="mt-3"> | ||
<div class="flex justify-between"> | ||
<FormGroup> | ||
<FormLabel for="email"> | ||
E-mail uczelniany | ||
</FormLabel> | ||
<TextInput id="email" v-model="form.email" :error="form.errors.email" type="email" /> | ||
<FormError :error="form.errors.email" class="mt-2" /> | ||
</FormGroup> | ||
<FormGroup> | ||
<FormLabel for="github_handle"> | ||
Github link | ||
</FormLabel> | ||
<TextInput id="github_handle" v-model="form.github_handle" :error="form.errors.github_handle" /> | ||
<FormError :error="form.errors.github_handle" class="mt-2" /> | ||
</FormGroup> | ||
<FormGroup> | ||
<FormLabel for="alternative_channel"> | ||
Alternatywny kontakt | ||
</FormLabel> | ||
<TextInput id="alternative_channel" v-model="form.alternative_channel" :error="form.errors.alternative_channel" /> | ||
<FormError :error="form.errors.alternative_channel" class="mt-2" /> | ||
</FormGroup> | ||
</div> | ||
<div class="flex justify-end space-x-3 py-3"> | ||
<SecondaryButton href="/dashboard"> | ||
Cofnij | ||
</SecondaryButton> | ||
<SubmitButton> | ||
Zapisz | ||
</SubmitButton> | ||
</div> | ||
</Section> | ||
</form> | ||
</DashboardLayout> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.