// CommunityPostController.php
public function edit(Community $community, Post $post)
{
$this->authorize('update', $post);
return view("posts.edit", compact('community', 'post'));
}
// posts/edit.blade.php
@extends('layouts.app')
@section('content')
<section class="section hero is-fullheight-with-navbar">
<div class="hero-body">
<div class="container">
<div class="columns is-centered">
<div class="column is-8">
@component('components.card')
@slot('title')
{{ $community->name }} - {{ __('Edit post') }}
@endslot
<form method="POST" action="{{ route('communities.posts.update', [$community, $post]) }}" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="field">
<label class="label" for="post_text">{{ __('Title') }}</label>
<div class="control">
<input id="title" type="text" class="input is-static" name="title"
value="{{ $post->title }}" readonly>
</div>
@error('title')
<p class="help is-danger" role="alert">
{{ $message }}
</p>
@enderror
</div>
<div class="field">
<label class="label" for="post_text">{{ __('Text') }}</label>
<div class="control">
<textarea id="post_text" name="post_text"
class="textarea @error('post_text') is-danger @enderror"
placeholder="Text (optional)">{{ $post->post_text }}</textarea>
</div>
@error('post_text')
<p class="help is-danger" role="alert">
{{ $message }}
</p>
@enderror
</div>
<div class="field">
<label class="label" for="post_image">{{ __('Image') }}</label>
<div class="control">
<div class="file">
<label class="file-label">
<input class="file-input" type="file" name="post_image">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Upload
</span>
</span>
</label>
</div>
</div>
@error('post_image')
<p class="help is-danger" role="alert">
{{ $message }}
</p>
@enderror
</div>
<div class="field">
<label class="label" for="post_link">{{ __('Link') }}</label>
<div class="control">
<input id="post_link" type="text" class="input @error('post_link') is-danger @enderror"
name="post_link" value="{{ $post->post_link }}" placeholder="Url">
</div>
@error('post_link')
<p class="help is-danger" role="alert">
{{ $message }}
</p>
@enderror
</div>
<hr>
<div class="field is-grouped is-grouped-right">
<p class="control">
<a class="button is-rounded" href="{{ route('communities.show', $community) }}">
<strong>{{ __('Cancel') }}</strong>
</a>
</p>
<p class="control">
<button type="submit" class="button is-info is-rounded">
<strong>{{ __('Save') }}</strong>
</button>
</p>
</div>
</form>
@endcomponent
</div>
</div>
</div>
</div>
</section>
@endsection
// communities/show.blade.php
// post edit 링크
@can('update', $post)
<a href="{{ route('communities.posts.edit', [$community, $post]) }}" class="button is-white has-text-weight-bold has-text-grey">
<span class="icon is-small">
<i class="far fa-edit"></i>
</span>
<span>{{ __('Edit') }}</span>
</a>
<button class="button is-white has-text-weight-bold has-text-grey">
<span class="icon is-small">
<i class="far fa-trash-alt"></i>
</span>
<span>{{ __('Delete') }}</span>
</button>
@endcan
git add .
git commit -m "feat: create post edit view"