<?php
namespace TourOperatorProAdmin\app\models;
defined('_TOUROPERATOR_EXEC') or die;

use Exception;
use TourOperatorPro\Factory;
use TourOperatorPro\Language\Text;
use TourOperatorPro\Mvc\Model\ModelForm;
use TourOperatorPro\Form\Form;
use TourOperatorPro\Mvc\Model\ModelList;
use TourOperatorPro\Registry\Registry;
class SmscontentModel extends ModelForm
{
    /**
     * @var string
     */
    public $context = "smscontent";
    /**
     * @var string
     */
    public $table_name = "smscontent";
    
    public function save($data = array())
    {

        if ($data){
            $err = array();
            if ($data['title_sms'] == '' || $data['title_sms'] == 'Enter your phone register') $err['title_sms'] = 'phone register is required';
            if ($data['content_sms'] == '' || $data['content_sms'] == 'Enter your content sms') $err['content_sms'] = 'content sms is required';
            if ($data['action_sms'] == '' || $data['action_sms'] == 'Enter your action sms') $err['action_sms'] = ' action sms  is required';
            if ($data['sms_suplier_id'] == '' || $data['sms_suplier_id'] == 'Enter your sms suplier') $err['sms_suplier_id'] = 'sms suplier  is required';
            if (empty($err)){
                $item =  parent::save($data); // TODO: Change the autogenerated stub
            }else{
                $er = (object)$err;
                throw new Exception(Text::_echo(
                    '<div class="alert alert-danger" style="width: 30%; margin: 0 auto; text-align: center">
                        '.((!empty($er->title_sms)) ?'<strong>'.$er->title_sms.'</strong></br>' : false) .'
                        '.((!empty($er->content_sms)) ?'<strong>'.$er->content_sms.'</strong></br>' : false) .'
                        '.((!empty($er->action_sms)) ?'<strong>'.$er->action_sms.'</strong></br>' : false) .'
                        '.((!empty($er->sms_suplier_id)) ?'<strong>'.$er->sms_suplier_id.'</strong></br>' : false) .'
                </div>'
                ));
            }

        }
        return $item;
    }


}
