This commit is contained in:
parent
01aa7ad404
commit
e7d517edff
@ -146,7 +146,7 @@ class NewsController extends Controller
|
|||||||
if ($request->isMethod('post')) {
|
if ($request->isMethod('post')) {
|
||||||
$messages = [
|
$messages = [
|
||||||
'required' => ':attribute は、必ず入力してください。',
|
'required' => ':attribute は、必ず入力してください。',
|
||||||
'open_datetime.date_format' => '公開日時は :format 形式(YYYY-MM-DD HH:MM:SS)で入力してください。',
|
'open_datetime.date_format' => '公開日時は :format 形式(YYYY-MM-DD)で入力してください。',
|
||||||
];
|
];
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'news' => 'ニュース内容',
|
'news' => 'ニュース内容',
|
||||||
@ -155,7 +155,7 @@ class NewsController extends Controller
|
|||||||
];
|
];
|
||||||
$v = $request->validate([
|
$v = $request->validate([
|
||||||
'news' => 'required|string',
|
'news' => 'required|string',
|
||||||
'open_datetime' => 'required|date_format:Y-m-d H:i:s',
|
'open_datetime' => 'required|date_format:Y-m-d',
|
||||||
'link_url' => 'nullable|string|max:255',
|
'link_url' => 'nullable|string|max:255',
|
||||||
'image1_filename' => 'nullable|string|max:255',
|
'image1_filename' => 'nullable|string|max:255',
|
||||||
'image2_filename' => 'nullable|string|max:255',
|
'image2_filename' => 'nullable|string|max:255',
|
||||||
@ -165,7 +165,7 @@ class NewsController extends Controller
|
|||||||
// 更新
|
// 更新
|
||||||
DB::table($this->table)->where($this->pk, $id)->update([
|
DB::table($this->table)->where($this->pk, $id)->update([
|
||||||
'news' => $v['news'],
|
'news' => $v['news'],
|
||||||
'open_datetime' => $v['open_datetime'],
|
'open_datetime' => $v['open_datetime'] . ' 00:00:00',
|
||||||
'link_url' => $v['link_url'] ?? null,
|
'link_url' => $v['link_url'] ?? null,
|
||||||
'image1_filename' => $v['image1_filename'] ?? null,
|
'image1_filename' => $v['image1_filename'] ?? null,
|
||||||
'image2_filename' => $v['image2_filename'] ?? null,
|
'image2_filename' => $v['image2_filename'] ?? null,
|
||||||
|
|||||||
@ -6,7 +6,9 @@
|
|||||||
<div class="content-header">
|
<div class="content-header">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-lg-6"><h1 class="m-0 text-dark">新規</h1></div>
|
<div class="col-lg-6">
|
||||||
|
<h1 class="m-0 text-dark">新規</h1>
|
||||||
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<ol class="breadcrumb float-sm-right text-sm">
|
<ol class="breadcrumb float-sm-right text-sm">
|
||||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
||||||
@ -23,7 +25,9 @@
|
|||||||
|
|
||||||
{{-- ▼ バリデーションエラー表示 --}}
|
{{-- ▼ バリデーションエラー表示 --}}
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
<div class="alert alert-danger"><ul class="mb-0">@foreach($errors->all() as $e)<li>{{ $e }}</li>@endforeach</ul></div>
|
<div class="alert alert-danger">
|
||||||
|
<ul class="mb-0">@foreach($errors->all() as $e)<li>{{ $e }}</li>@endforeach</ul>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{{-- ▼ 成功メッセージ表示 --}}
|
{{-- ▼ 成功メッセージ表示 --}}
|
||||||
@ -44,9 +48,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>公開日時<span class="text-danger">*</span></label>
|
<label>公開日時<span class="text-danger">*</span></label>
|
||||||
<input type="text" name="open_datetime" class="form-control" placeholder="YYYY-MM-DD HH:MM:SS"
|
<input type="date"
|
||||||
value="{{ old('open_datetime') }}" required>
|
name="open_date"
|
||||||
|
class="form-control"
|
||||||
|
value="{{ old('open_date') }}"
|
||||||
|
required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>リンクURL</label>
|
<label>リンクURL</label>
|
||||||
<input type="text" name="link_url" class="form-control" value="{{ old('link_url') }}">
|
<input type="text" name="link_url" class="form-control" value="{{ old('link_url') }}">
|
||||||
@ -77,13 +85,16 @@
|
|||||||
<div class="imgbox-title">画像1</div>
|
<div class="imgbox-title">画像1</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label class="small text-muted d-block mb-1">画像1URLスペース</label>
|
<label class="small text-muted d-block mb-1">画像1URLスペース</label>
|
||||||
<input type="text" name="image1_filename" id="image1_url" class="form-control" placeholder="http(s)://..." value="{{ old('image1_filename') }}">
|
<input type="text" name="image1_filename" id="image1_url" class="form-control"
|
||||||
|
placeholder="https://..." value="{{ old('image1_filename') }}">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="small text-muted d-block mb-1">画像1表示スペース</label>
|
<label class="small text-muted d-block mb-1">画像1表示スペース</label>
|
||||||
<div class="imgbox-preview">
|
<div class="imgbox-preview">
|
||||||
<img id="image1_preview" src="{{ old('image1_filename') }}" alt="" style="display: {{ old('image1_filename') ? 'block' : 'none' }};">
|
<img id="image1_preview" src="{{ old('image1_filename') }}" alt=""
|
||||||
<span id="image1_placeholder" class="text-muted" style="display: {{ old('image1_filename') ? 'none' : 'block' }};">プレビューなし</span>
|
style="display: {{ old('image1_filename') ? 'block' : 'none' }};">
|
||||||
|
<span id="image1_placeholder" class="text-muted"
|
||||||
|
style="display: {{ old('image1_filename') ? 'none' : 'block' }};">プレビューなし</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -94,13 +105,16 @@
|
|||||||
<div class="imgbox-title">画像2</div>
|
<div class="imgbox-title">画像2</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label class="small text-muted d-block mb-1">画像2URLスペース</label>
|
<label class="small text-muted d-block mb-1">画像2URLスペース</label>
|
||||||
<input type="text" name="image2_filename" id="image2_url" class="form-control" placeholder="http(s)://..." value="{{ old('image2_filename') }}">
|
<input type="text" name="image2_filename" id="image2_url" class="form-control"
|
||||||
|
placeholder="https://..." value="{{ old('image2_filename') }}">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="small text-muted d-block mb-1">画像2表示スペース</label>
|
<label class="small text-muted d-block mb-1">画像2表示スペース</label>
|
||||||
<div class="imgbox-preview">
|
<div class="imgbox-preview">
|
||||||
<img id="image2_preview" src="{{ old('image2_filename') }}" alt="" style="display: {{ old('image2_filename') ? 'block' : 'none' }};">
|
<img id="image2_preview" src="{{ old('image2_filename') }}" alt=""
|
||||||
<span id="image2_placeholder" class="text-muted" style="display: {{ old('image2_filename') ? 'none' : 'block' }};">プレビューなし</span>
|
style="display: {{ old('image2_filename') ? 'block' : 'none' }};">
|
||||||
|
<span id="image2_placeholder" class="text-muted"
|
||||||
|
style="display: {{ old('image2_filename') ? 'none' : 'block' }};">プレビューなし</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -110,32 +124,37 @@
|
|||||||
{{-- 表示モード(デフォルト:非表示) --}}
|
{{-- 表示モード(デフォルト:非表示) --}}
|
||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label class="d-block">表示モード <span class="text-danger">*</span></label>
|
<label class="d-block">表示モード <span class="text-danger">*</span></label>
|
||||||
|
|
||||||
|
{{-- 下書き(非表示) --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_draft" value="2" required
|
<input class="form-check-input" type="radio" name="mode" id="mode_draft" value="1" required
|
||||||
@checked(old('mode','0')=='2')>
|
@checked(old('mode', $row->mode ?? '') == '1')>
|
||||||
<label class="form-check-label" for="mode_draft">下書き(非表示)</label>
|
<label class="form-check-label" for="mode_draft">下書き(非表示)</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 公開 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_public" value="1"
|
<input class="form-check-input" type="radio" name="mode" id="mode_public" value="2" @checked(old('mode', $row->mode ?? '') == '2')>
|
||||||
@checked(old('mode','0')=='1')>
|
|
||||||
<label class="form-check-label" for="mode_public">公開</label>
|
<label class="form-check-label" for="mode_public">公開</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 自動公開 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_auto" value="3"
|
<input class="form-check-input" type="radio" name="mode" id="mode_auto" value="3" @checked(old('mode', $row->mode ?? '') == '3')>
|
||||||
@checked(old('mode','0')=='3')>
|
|
||||||
<label class="form-check-label" for="mode_auto">自動公開</label>
|
<label class="form-check-label" for="mode_auto">自動公開</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 非表示 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_hidden" value="0"
|
<input class="form-check-input" type="radio" name="mode" id="mode_hidden" value="4" @checked(old('mode', $row->mode ?? '') == '4')>
|
||||||
@checked(old('mode','0')=='0')>
|
|
||||||
<label class="form-check-label" for="mode_hidden">非表示</label>
|
<label class="form-check-label" for="mode_hidden">非表示</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-right">
|
<div class="text-left">
|
||||||
<a href="{{ route('news') }}" class="btn btn-default">戻る</a>
|
|
||||||
<!-- 変更点: class="register" を付与して app.js の汎用確認を使用 -->
|
|
||||||
<button type="button" class="btn btn-default register" id="register-btn">登録</button>
|
<button type="button" class="btn btn-default register" id="register-btn">登録</button>
|
||||||
|
<!-- 変更点: class="register" を付与して app.js の汎用確認を使用 -->
|
||||||
|
<a href="{{ route('news') }}" class="btn btn-default">戻る</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -147,13 +166,34 @@
|
|||||||
@push('styles')
|
@push('styles')
|
||||||
<style>
|
<style>
|
||||||
/* 画像ボックスの体裁 */
|
/* 画像ボックスの体裁 */
|
||||||
.imgbox { border:1px solid #ced4da; border-radius:.25rem; }
|
.imgbox {
|
||||||
.imgbox-title { background:#f4f6f9; border-bottom:1px solid #ced4da; padding:.5rem .75rem; font-weight:600; }
|
border: 1px solid #ced4da;
|
||||||
.imgbox-preview {
|
border-radius: .25rem;
|
||||||
border:1px solid #ced4da; border-radius:.25rem; background:#f8f9fa;
|
}
|
||||||
height:200px; display:flex; align-items:center; justify-content:center; overflow:hidden;
|
|
||||||
|
.imgbox-title {
|
||||||
|
background: #f4f6f9;
|
||||||
|
border-bottom: 1px solid #ced4da;
|
||||||
|
padding: .5rem .75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgbox-preview {
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
border-radius: .25rem;
|
||||||
|
background: #f8f9fa;
|
||||||
|
height: 200px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgbox-preview img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
.imgbox-preview img { max-width:100%; max-height:100%; display:block; }
|
|
||||||
</style>
|
</style>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|||||||
@ -41,9 +41,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>公開日時<span class="text-danger">*</span></label>
|
<label>公開日時<span class="text-danger">*</span></label>
|
||||||
<input type="text" name="open_datetime" class="form-control" placeholder="YYYY-MM-DD HH:MM:SS"
|
<input type="date"
|
||||||
value="{{ old('open_datetime', $news->open_datetime) }}" required>
|
name="open_datetime"
|
||||||
|
class="form-control"
|
||||||
|
value="{{ old('open_datetime', !empty($news->open_datetime) ? \Carbon\Carbon::parse($news->open_datetime)->format('Y-m-d') : '') }}"
|
||||||
|
required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>リンクURL</label>
|
<label>リンクURL</label>
|
||||||
<input type="text" name="link_url" class="form-control" value="{{ old('link_url', $news->link_url) }}">
|
<input type="text" name="link_url" class="form-control" value="{{ old('link_url', $news->link_url) }}">
|
||||||
@ -110,34 +115,43 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- 表示モード(ラジオ・必須/新規画面と同一UI) --}}
|
{{-- 表示モード(デフォルト:非表示) --}}
|
||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label class="d-block">表示モード <span class="text-danger">*</span></label>
|
<label class="d-block">表示モード <span class="text-danger">*</span></label>
|
||||||
|
|
||||||
|
{{-- 下書き(非表示) --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_draft" value="2" required
|
<input class="form-check-input" type="radio" name="mode" id="mode_draft" value="1" required
|
||||||
@checked(old('mode', (string)$news->mode)=='2')>
|
@checked(old('mode', $news->mode) == 1)>
|
||||||
<label class="form-check-label" for="mode_draft">下書き(非表示)</label>
|
<label class="form-check-label" for="mode_draft">下書き(非表示)</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 公開 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_public" value="1"
|
<input class="form-check-input" type="radio" name="mode" id="mode_public" value="2"
|
||||||
@checked(old('mode', (string)$news->mode)=='1')>
|
@checked(old('mode', $news->mode) == 2)>
|
||||||
<label class="form-check-label" for="mode_public">公開</label>
|
<label class="form-check-label" for="mode_public">公開</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 自動公開 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_auto" value="3"
|
<input class="form-check-input" type="radio" name="mode" id="mode_auto" value="3"
|
||||||
@checked(old('mode', (string)$news->mode)=='3')>
|
@checked(old('mode', $news->mode) == 3)>
|
||||||
<label class="form-check-label" for="mode_auto">自動公開</label>
|
<label class="form-check-label" for="mode_auto">自動公開</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- 非表示 --}}
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="radio" name="mode" id="mode_hidden" value="0"
|
<input class="form-check-input" type="radio" name="mode" id="mode_hidden" value="4"
|
||||||
@checked(old('mode', (string)$news->mode)=='0')>
|
@checked(old('mode', $news->mode) == 4)>
|
||||||
<label class="form-check-label" for="mode_hidden">非表示</label>
|
<label class="form-check-label" for="mode_hidden">非表示</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-right">
|
|
||||||
|
<div class="text-left">
|
||||||
|
<button type="button" class="btn btn-default" id="register_edit">登録</button>
|
||||||
<a href="{{ route('news') }}" class="btn btn-default">戻る</a>
|
<a href="{{ route('news') }}" class="btn btn-default">戻る</a>
|
||||||
<button type="button" class="btn btn-default" id="register_edit">保存</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user