本文整理汇总了PHP中Service::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::save方法的具体用法?PHP Service::save怎么用?PHP Service::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddAjax
public function actionAddAjax()
{
if (!isset(Yii::app()->user->storeID)) {
$data['message'] = '<div class="alert alert-success">Store not found. </div>';
echo json_encode($data);
exit;
}
$model = new Service();
if (isset($_POST['Service'])) {
$model->attributes = $_POST['Service'];
$data = array();
$mss = '';
if (count($data) == 0) {
$model->pk_s_id = '-1';
$model->i_flag_sync = 1;
$model->i_flag_deleted = 0;
$model->i_disable = 0;
if ($model->save()) {
$model->pk_s_id = 'SV' . $model->id;
if ($model->save()) {
$data['option'] = '<option selected="selected" value ="' . $model->pk_s_id . '">' . $model->s_name . '</option>';
$data['message'] = '<div class="alert alert-success">Success! Account created. </div>';
} else {
$model->delete();
$data['message'] = '<div class="alert alert-danger">Error! Please try again later.</div>';
}
} else {
$data['message'] = json_encode($model->errors);
//'<div class="alert alert-danger">Error! Please try again later2.</div>';
}
}
echo json_encode($data);
}
}
示例2: save
/**
* Updates or inserts a contact
* @param Service $service
* @return self
* @throws NotValidException
*/
public function save(Service $service)
{
if (!$this->validate()) {
throw new NotValidException('Unable to validate contact');
}
return $this->reload($service->save($this));
}
示例3: create
public function create($permalink = null)
{
$event = self::load_event($permalink);
$service = new Service();
if ($this->post) {
$service->event_id = $event->id;
$service->cost = UnMoney($_POST['cost']);
$service->capacity = $_POST['capacity'];
$service->participant = $_POST['participant'];
$service->hidden = $_POST['hidden'];
$service->name = $_POST['name'];
$service->description = $_POST['description'];
$service->advanced = $_POST['advanced'];
$service->question = $_POST['question'];
$service->max_per_signup = $_POST['max_per_signup'];
$service->discountable = $this->PostData("discountable");
if ($service->save()) {
Site::Flash("notice", "The service has been added");
Redirect("admin/events/{$event->permalink}/services");
}
}
$this->assign("event", $event);
$this->assign("service", $service);
$this->title = "Add Service";
$this->render("service/create.tpl");
}
示例4: update_service
public function update_service($service_id = NULL)
{
if (is_null($service_id)) {
add_error_flash_message('Služba sa nenašla.');
redirect(site_ur('services'));
}
$this->db->trans_begin();
$service = new Service();
$service->get_by_id((int) $service_id);
if (!$service->exists()) {
$this->db->trans_rollback();
add_error_flash_message('Služba sa nenašla.');
redirect(site_ur('services'));
}
build_validator_from_form($this->get_form());
if ($this->form_validation->run()) {
$service_data = $this->input->post('service');
$service->from_array($service_data, array('title', 'price'));
if ($service->save() && $this->db->trans_status()) {
$this->db->trans_commit();
add_success_flash_message('Služba s ID <strong>' . $service->id . '</strong> bola úspešne upravená.');
redirect(site_url('services'));
} else {
$this->db->trans_rollback();
add_error_flash_message('Službu s ID <strong>' . $service->id . '</strong> sa nepodarilo upraviť.');
redirect(site_url('services/edit_service/' . (int) $service->id));
}
} else {
$this->db->trans_rollback();
$this->edit_service($service->id);
}
}
示例5: save
function save($id = FALSE)
{
if ($_POST) {
$category = new Category($id);
$_POST['module'] = "services";
$_POST['name'] = lang_encode($_POST['name']);
$category->from_array($_POST);
$category->save();
if ($_POST['title']['th']) {
foreach ($_POST['title']['th'] as $key => $item) {
$service = new Service(@$_POST['sub_id'][$key]);
if ($item) {
$title = array('th' => $_POST['title']['th'][$key], 'en' => $_POST['title']['en'][$key]);
$service->title = lang_encode($title);
$service->category_id = $category->id;
$service->save();
}
}
// exit;
}
set_notify('success', lang('save_data_complete'));
}
// redirect($_POST['referer']);
// redirect($_SERVER['HTTP_REFERER']);
redirect('services/admin/services');
}
示例6: _start
/**
* SetUp
*/
protected function _start()
{
$this->table = Doctrine::getTable('OperationNotification');
// Создать услугу с захардкоженным ID
$service = new Service();
$service->setKeyword(Service::SERVICE_SMS);
$service->save();
}
示例7: store
/**
* Store a newly created resource in storage.
* POST /services
*
* @return Response
*/
public function store()
{
$service = new Service();
$service->service = Input::get('service');
$service->save();
Flash::message('Service Added!');
return Redirect::route('add_service');
}
示例8: testIndex
/**
* Тест /services/index
*
*/
public function testIndex()
{
$user = $this->helper->makeUser();
$this->authenticateUser($user);
$user->save();
$service = new Service();
$service->price = 100;
$service->name = "Уникальное имя услуги " . uniqid();
$service->save();
$this->browser->get($this->generateUrl('services'))->with('response')->begin()->isStatusCode(200)->matches('/(' . $service->name . ')/i')->end();
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('cs_service_types')->delete();
$services = array("Theme", "Project", "Fix Bug");
foreach ($services as $service) {
$sv = new Service();
$sv->name = $service;
$sv->description = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s";
$sv->save();
}
}
示例10: storeService
public function storeService()
{
$advisor = Auth::user();
// If form validation passes:
$service = new Service();
$service->name = Input::get('name');
if (Input::get('notes')) {
$service->notes = Input::get('notes');
}
$service->save();
$advisor->services()->save($service);
return Redirect::intended('advisor.dashboard');
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Service();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Service'])) {
$model->attributes = $_POST['Service'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例12: submit
public function submit()
{
$facility1 = $this->input->post('spoint');
$service = $this->input->post('facility');
$u = new Service();
$u->facility_id = $service;
$u->service_point = $facility1;
$u->save();
$data['title'] = "Service Points";
$data['content_view'] = "facility_service";
$data['banner_text'] = "Service Points";
$data['quick_link'] = "facility_service";
$this->load->view("template", $data);
}
示例13: install
/** install($name)
Method that installs the relevant plugin.
$name just sends the plugin name. Useful
for schema adding.
*/
public function install($name)
{
$sql = "CREATE TABLE capone\n (cID INTEGER NOT NULL AUTO_INCREMENT,\n cImageID INTEGER NOT NULL,\n cOSID INTEGER NOT NULL,\n cKey VARCHAR(250) NOT NULL,\n PRIMARY KEY(cID),\n INDEX new_index (cImageID),\n INDEX new_index2 (cKey))\n ENGINE = MyISAM";
if ($this->DB->query($sql)) {
$CaponeDMI = new Service(array('name' => 'FOG_PLUGIN_CAPONE_DMI', 'description' => 'This setting is used for the capone module to set the DMI field used.', 'value' => '', 'category' => 'Plugin: ' . $name));
$CaponeDMI->save();
$CaponeRegEx = new Service(array('name' => 'FOG_PLUGIN_CAPONE_REGEX', 'description' => 'This setting is used for the capone module to set the reg ex used.', 'value' => '', 'category' => 'Plugin: ' . $name));
$CaponeRegEx->save();
$CaponeShutdown = new Service(array('name' => 'FOG_PLUGIN_CAPONE_SHUTDOWN', 'description' => 'This setting is used for the capone module to set the shutdown after imaging.', 'value' => '', 'category' => 'Plugin: ' . $name));
$CaponeShutdown->save();
return true;
}
return false;
}
示例14: createService
/**
* Creates a new service and returns the service Object.
* @return [type] [description]
*/
public function createService($name, $notes, $duration, $id = null)
{
$advisor = Advisor::find($id);
$service = new Service();
$service->name = $name;
$service->duration = $duration;
$service->notes = $notes;
$service->save();
if ($id == null) {
return $service;
}
$advisor->services()->attach($service);
return $service;
}
示例15: saveService
public function saveService()
{
$service = ['name' => Input::get('name')];
$rules = ['name' => 'required'];
$valid = Validator::make($service, $rules);
if ($valid->passes()) {
$service = new Service($service);
$service->save();
if (!empty(Input::get('pets'))) {
$service->pets()->sync(Input::get('pets'));
}
return Redirect::to('/services')->with('success', 'Service is saved!');
} else {
return Redirect::back()->withErrors($valid)->withInput();
}
}