作者 Your Name

gx

  1 +<?php
  2 +
  3 +namespace App\Http\Requests\Bside\AyrRelease;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class AyrReleaseRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 + /**
  19 + * Get the validation rules that apply to the request.
  20 + *
  21 + * @return array
  22 + */
  23 + public function rules()
  24 + {
  25 + return [
  26 + 'title'=>'required',
  27 + 'images'=>'required',
  28 + 'video'=>'required',
  29 + 'content'=>'required',
  30 + 'share_id'=>'required',
  31 + 'platforms'=>'required',
  32 + 'idempotency_key'=>'required',
  33 + ];
  34 + }
  35 +
  36 + public function messages()
  37 + {
  38 + return [
  39 + 'name.required'=>'参数错误',
  40 + ];
  41 + }
  42 +}
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * @author:dc
  9 + * @time 2023/5/10 14:31
  10 + * Class BTemplateData
  11 + * @package App\Models\Template
  12 + */
  13 +class BTemplateData extends \App\Models\Base{
  14 +
  15 +
  16 + protected $table = 'gl_web_template_data';
  17 +
  18 +
  19 + protected $hidden = ['project_id'];
  20 +
  21 +
  22 +
  23 + /**
  24 + * 插入/修改
  25 + * @param int $project_id
  26 + * @param array $data
  27 + * @return mixed
  28 + * @author:dc
  29 + * @time 2023/5/10 10:23
  30 + */
  31 + public static function _save(int $project_id, array $data)
  32 + {
  33 +
  34 + $model = static::where([
  35 + 'project_id'=>$project_id,
  36 + 'template_id'=>$data['template_id'],
  37 + 'type' => $data['type'],
  38 + 'tag' => $data['tag'],
  39 + ])->first();
  40 +
  41 + if(!$model){
  42 + $model = new static();
  43 + $model->project_id = $project_id;
  44 + $model->template_id = $data['template_id'];
  45 + $model->type = $data['type'];
  46 + $model->tag = $data['tag'];
  47 + }
  48 +
  49 + $model->css = $data['css']??'';
  50 + $model->script = $data['script']??'';
  51 + $model->html = $data['html']??'';
  52 + $model->data_ext = $data['data_ext']??'';
  53 + $model->data_source = $data['data_source']??'all';
  54 + $model->data_source_id = $data['data_source_id']??0;
  55 +
  56 + $model->save();
  57 +
  58 + return $model->id;
  59 +
  60 + }
  61 +
  62 +
  63 +}
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + *
  9 + * 模板
  10 + * @author:dc
  11 + * @time 2023/5/9 13:56
  12 + * Class ATemplate
  13 + * @package App\Models\Template
  14 + */
  15 +class BTemplateHtml extends \App\Models\Base{
  16 +
  17 +
  18 + protected $table = 'gl_web_template_html';
  19 +
  20 +
  21 + protected $hidden = ['deleted_at','project_id'];
  22 +
  23 +
  24 + use SoftDeletes;
  25 +
  26 +
  27 +
  28 +
  29 + /**
  30 + * 插入
  31 + * @param $project_id
  32 + * @param $data
  33 + * @return mixed
  34 + * @author:dc
  35 + * @time 2023/5/10 10:23
  36 + */
  37 + public static function _insert($project_id,$data)
  38 + {
  39 +
  40 + $model = new static();
  41 +
  42 + $model->project_id = $project_id;
  43 +
  44 + $model->template_id = $data['template_id'];
  45 +
  46 + $model->name = $data['name'];
  47 + $model->type = $data['type'];
  48 + $model->is_edit = $data['is_edit'];
  49 + $model->css = $data['css'];
  50 + $model->script = $data['script'];
  51 + $model->html = $data['html'];
  52 + $model->data_ext = $data['data_ext'];
  53 +
  54 + $model->save();
  55 +
  56 + return $model->id;
  57 +
  58 + }
  59 +
  60 +
  61 +}