This commit is contained in:
Andras Bacsai 2023-06-22 09:33:26 +02:00
parent 0d5c4b83bb
commit cfe9aed42a
7 changed files with 72 additions and 3 deletions

View File

@ -14,6 +14,16 @@ public function all()
return view('projects', ['projects' => $projects]);
}
public function edit()
{
$projectUuid = request()->route('project_uuid');
$teamId = session('currentTeam')->id;
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
if (!$project) {
return redirect()->route('dashboard');
}
return view('project.edit', ['project' => $project]);
}
public function show()
{
$projectUuid = request()->route('project_uuid');

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Livewire\Project;
use App\Models\Project;
use Livewire\Component;
class Edit extends Component
{
public Project $project;
protected $rules = [
'project.name' => 'required|min:3|max:255',
'project.description' => 'nullable|string|max:255',
];
public function submit()
{
$this->validate();
try {
$this->project->save();
$this->emit('saved');
} catch (\Exception $e) {
return general_error_handler($e, $this);
}
}
}

View File

@ -0,0 +1,9 @@
<div>
<h1>{{ data_get($project, 'name') }}</h1>
<div class="pt-2 pb-10">Edit project details</div>
<form wire:submit.prevent='submit' class="flex items-end gap-2 ">
<x-forms.input label="Name" id="project.name" />
<x-forms.input label="Description" id="project.description" />
<x-forms.button type="submit">Save</x-forms.button>
</form>
</div>

View File

@ -0,0 +1,3 @@
<x-layout>
<livewire:project.edit :project="$project" />
</x-layout>

View File

@ -3,13 +3,34 @@
<div class="pt-2 pb-10 ">All Projects</div>
<div class="grid gap-2 lg:grid-cols-2">
@forelse ($projects as $project)
<a href="{{ route('project.show', ['project_uuid' => data_get($project, 'uuid')]) }}"
class="box">{{ $project->name }}</a>
<div class="gap-2 cursor-pointer box group" x-data x-on:click="goto('{{ $project->uuid }}')">
<div class="flex flex-col mx-6">
<a class=" group-hover:text-white hover:no-underline"
href="{{ route('project.show', ['project_uuid' => data_get($project, 'uuid')]) }}">{{ $project->name }}</a>
<a class="text-xs group-hover:text-white hover:no-underline"
href="{{ route('project.show', ['project_uuid' => data_get($project, 'uuid')]) }}">{{ $project->description }}</a>
</div>
<div class="flex-1"></div>
<a class="mx-4 rounded hover:text-white"
href="{{ route('project.edit', ['project_uuid' => data_get($project, 'uuid')]) }}"><svg
xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path
d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" />
<path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
</svg></a>
</div>
@empty
<div>
<div>No project found.</div>
<x-use-magic-bar />
</div>
@endforelse
<script>
function goto(uuid) {
window.location.href = '/project/' + uuid;
}
</script>
</div>
</x-layout>

View File

@ -47,6 +47,7 @@
Route::middleware(['auth'])->group(function () {
Route::get('/projects', [ProjectController::class, 'all'])->name('projects');
Route::get('/project/{project_uuid}/edit', [ProjectController::class, 'edit'])->name('project.edit');
Route::get('/project/{project_uuid}', [ProjectController::class, 'show'])->name('project.show');
Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');