@extends('layout.app') @section('content') @php $isEdit = (bool)$template->id; $params = old('params') ?: ($isEdit ? $template->params->map(function ($p) { return [ 'param' => $p->param, 'source' => $p->source, 'max_length' => $p->max_length, 'is_required' => $p->is_required, ]; })->toArray() : []); @endphp

{{ $title }}

{!! Form::open([ 'url' => $isEdit ? route('zns-templates.update', $template->id) : route('zns-templates.store'), 'method' => $isEdit ? 'put' : 'post', 'id' => 'zns-form', ]) !!}
@if($errors->any())
@foreach($errors->all() as $error)
{{ $error }}
@endforeach
@endif
{!! Form::label('name', 'Tên mẫu tin', ['class' => 'control-label required']) !!} {!! Form::text('name', old('name', $template->name), ['class' => 'form-control', 'placeholder' => 'VD: Nhắc lịch hẹn']) !!}
{!! Form::label('event', 'Sự kiện bắn tin', ['class' => 'control-label required']) !!} {!! Form::select('event', $events, old('event', $template->event), ['class' => 'form-control', 'id' => 'zns-event']) !!}
{!! Form::label('template_id', 'Template ID (ZNS)', ['class' => 'control-label required']) !!} {!! Form::text('template_id', old('template_id', $template->template_id), ['class' => 'form-control']) !!}
{!! Form::label('status', 'Bật', ['class' => 'control-label']) !!}
status) == \App\Constants\StatusCode::ON ? 'checked' : '' }}>
{!! Form::label('note', 'Ghi chú', ['class' => 'control-label']) !!} {!! Form::text('note', old('note', $template->note), ['class' => 'form-control']) !!}

Cấu trúc tham số (TempData)

Khai báo đúng tên params đã đăng ký với Zalo OA, rồi chọn nguồn dữ liệu tương ứng trong hệ thống. Khi gửi tin, hệ thống tự lấy giá trị theo nguồn đã chọn. Để trống nguồn nếu chưa cần dùng param đó.

@foreach($params as $i => $param) @endforeach
Tên params * Nguồn dữ liệu Độ dài tối đa Bắt buộc
{!! Form::close() !!}
@endsection @section('_script') @endsection