当前位置: 首页>>代码示例>>PHP>>正文


PHP Portfolio::save方法代码示例

本文整理汇总了PHP中Portfolio::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Portfolio::save方法的具体用法?PHP Portfolio::save怎么用?PHP Portfolio::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Portfolio的用法示例。


在下文中一共展示了Portfolio::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 public function add()
 {
     if (isset($_POST)) {
         $this->form_validation->set_rules('portfolio_name', 'Porfolio Name', 'required|is_unique[portfolios.portfolio_name]');
         $this->form_validation->set_rules('beginning_cap', 'Starting Capital', 'required|numeric|greater_than[0]');
         if ($this->form_validation->run()) {
             $portfolio = new Portfolio();
             $portfolio->portfolio_name = $this->input->post('portfolio_name');
             $portfolio->portfolio_description = $this->input->post('portfolio_description');
             $portfolio->beginning_cap = $this->input->post('beginning_cap');
             $portfolio->current_cap = $portfolio->beginning_cap;
             $portfolio->starting_date = date("Y-m-d H:i:s");
             $portfolio->user_id = $this->input->post('user_id') + 1;
             $checked = $this->input->post('commision_bool');
             if ((int) $checked == 1) {
                 $portfolio->commision_bool = 1;
             } else {
                 $portfolio->commision_bool = 0;
             }
             $portfolio->commision = $this->input->post('commision');
             $portfolio->save();
             redirect('portfolios');
         } else {
             $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
             $this->data['charts'] = 0;
             $this->load->view('dressings/header');
             $this->load->view('dressings/navbar');
             $this->load->view('add_portfolio', $this->data);
             $this->load->view('dressings/footer');
         }
     }
 }
开发者ID:geckoman413,项目名称:ci_cms,代码行数:32,代码来源:Portfolios.php

示例2: createAction

 /**
  * Creates a new portfolio
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "index"));
     }
     $portfolio = new Portfolio();
     $portfolio->title = $this->request->getPost("title");
     $portfolio->short_description = $this->request->getPost("short_description");
     $portfolio->body = $this->request->getPost("body");
     $portfolio->image = $this->request->getPost("image");
     $portfolio->status = $this->request->getPost("status");
     if (!$portfolio->save()) {
         foreach ($portfolio->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "new"));
     }
     $this->flash->success("portfolio was created successfully");
     return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "index"));
 }
开发者ID:noudr93,项目名称:noud.me,代码行数:23,代码来源:PortfolioController.php

示例3: envPortfolio

 protected function envPortfolio()
 {
     $portfolio = new Portfolio();
     $portfolio->picture = 'img/uploaded/2.jpg';
     $portfolio->title = 'My Project';
     $portfolio->description = 'This is my cute dog.';
     $portfolio->template_id = 1;
     $portfolio->save();
     $portfolio = new Portfolio();
     $portfolio->picture = 'img/uploaded/park.jpeg';
     $portfolio->title = 'My Project';
     $portfolio->description = 'This is my favorite park';
     $portfolio->template_id = 1;
     $portfolio->save();
     $portfolio2 = new Portfolio();
     $portfolio2->picture = 'img/uploaded/2.jpg';
     $portfolio2->title = 'My dog';
     $portfolio2->description = 'He is a cutie';
     $portfolio2->template_id = 2;
     $portfolio2->save();
     $portfolio21 = new Portfolio();
     $portfolio21->picture = 'img/uploaded/park.jpeg';
     $portfolio21->title = 'Best Park';
     $portfolio21->description = 'This is my favorite park';
     $portfolio21->template_id = 2;
     $portfolio21->save();
     $portfolio3 = new Portfolio();
     $portfolio3->picture = 'img/uploaded/2.jpg';
     $portfolio3->title = 'My Project';
     $portfolio3->description = 'Its pretty awesome';
     $portfolio3->template_id = 3;
     $portfolio3->save();
     $portfolio31 = new Portfolio();
     $portfolio31->picture = 'img/uploaded/park.jpeg';
     $portfolio31->title = 'My Project';
     $portfolio31->description = 'This is my favorite park';
     $portfolio31->template_id = 3;
     $portfolio31->save();
 }
开发者ID:resumeproductions,项目名称:Resume-Solutions,代码行数:39,代码来源:PortfoliosTableSeeder.php

示例4: add_portfolio

 public function add_portfolio()
 {
     if (!$this->securitypolicy->validateAccessRight(4, 'add')) {
         $this->load->view('access_denied');
     }
     $this->load->library('form_validation');
     $this->load->helper('form');
     $portfolio = new Portfolio();
     $data['showmsg'] = true;
     if ($this->form_validation->run() == false) {
         $data['status'] = 'error';
         $this->load->view('hotel_mngt_add_hotel_portfolio', $data);
     } else {
         $portfolio->save();
         if (!empty($portfolio->errors)) {
             $data['msg'] = $portfolio->errors;
             $data['status'] = 'error';
             $this->load->view('hotel_mngt_add_hotel_portfolio', $data);
         } else {
             $this->session->set_userdata(array("status" => "success"));
             redirect(site_url('Admin/add_portfolio'));
         }
     }
 }
开发者ID:albertfajarito,项目名称:dwh-revenue-monitoring,代码行数:24,代码来源:Portfolios.php

示例5: testSaveHabtmNoPrimaryData

 /**
  * testSaveHabtmNoPrimaryData method
  *
  * @return void
  */
 public function testSaveHabtmNoPrimaryData()
 {
     $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'ArticlesTag');
     $TestModel = new Article();
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')), false);
     $result = $TestModel->findById(2);
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $TestModel->id = 2;
     $data = array('Tag' => array('Tag' => array(2)));
     $result = $TestModel->save($data);
     $this->assertEquals($data['Tag'], $result['Tag']);
     $result = $TestModel->findById(2);
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => self::date()), 'Tag' => array(array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')));
     $this->assertEquals($expected, $result);
     $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio');
     $TestModel = new Portfolio();
     $result = $TestModel->findById(2);
     $expected = array('Portfolio' => array('id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2'), 'Item' => array(array('id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', 'ItemsPortfolio' => array('id' => 2, 'item_id' => 2, 'portfolio_id' => 2)), array('id' => 6, 'syfile_id' => 6, 'published' => '', 'name' => 'Item 6', 'ItemsPortfolio' => array('id' => 6, 'item_id' => 6, 'portfolio_id' => 2))));
     $this->assertEquals($expected, $result);
     $data = array('Item' => array('Item' => array(1, 2)));
     $TestModel->id = 2;
     $TestModel->save($data);
     $result = $TestModel->findById(2);
     $result['Item'] = Hash::sort($result['Item'], '{n}.id', 'asc');
     $expected = array('Portfolio' => array('id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2'), 'Item' => array(array('id' => 1, 'syfile_id' => 1, 'published' => '', 'name' => 'Item 1', 'ItemsPortfolio' => array('id' => 7, 'item_id' => 1, 'portfolio_id' => 2)), array('id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', 'ItemsPortfolio' => array('id' => 8, 'item_id' => 2, 'portfolio_id' => 2))));
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:33,代码来源:ModelWriteTest.php

示例6: store

 /**
  * Store a newly created template in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Template::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $template = new Template();
         $template->color = Input::get('color');
         $template->layout = Input::get('templateID');
         $template->user_id = Auth::id();
         $template->save();
         //Storing header info
         if (Input::has('headerJobTitle')) {
             $header = new Header1();
             $header->job_title = Input::get('headerJobTitle');
             $header->template_id = $template->id;
             if (Input::has('headerResumeTitle')) {
                 $header->description = Input::get('headerResumeTitle');
             }
             if (Input::hasFile('headerImage')) {
                 $header->picture = Input::file('headerImage')->move("images/uploaded/");
             }
             if (Input::has('headerJobTitle')) {
                 $header->description = Input::get('headerJobTitle');
             }
             $header->save();
         }
         //Storing adjectives for template 2
         if (Input::has('adjectives1')) {
             $header1 = new Header1();
             $header1->template_id = $template->id;
             $header1->adjective = Input::get('adjectives1');
             $header1->save();
         }
         if (Input::has('adjectives2')) {
             $header2 = new Header1();
             $header2->template_id = $template->id;
             $header2->adjective = Input::get('adjectives2');
             $header2->save();
         }
         if (Input::has('adjectives3')) {
             $header3 = new Header1();
             $header3->template_id = $template->id;
             $header3->adjective = Input::get('adjectives3');
             $header3->save();
         }
         //Checking for up to 6 skill inputs to be accpeted
         if (Input::has('skillPercent1') && Input::has('skillTitle1')) {
             $skill1 = new Skill();
             $skill1->template_id = $template->id;
             $skill1->percent = Input::get('skillPercent1');
             $skill1->skill_title = Input::get('skillTitle1');
             if (Input::has('skillDescription1')) {
                 $skill1->description = Input::get('skillDescription1');
             }
             if (Input::has('skillDescriptionTitle1')) {
                 $skill1->description_title = Input::get('skillDescriptionTitle1');
             }
             if (Input::has('hobbies1')) {
                 $skill1->description_title = Input::get('hobbies1');
             }
             $skill1->save();
         }
         if (Input::has('skillPercent2') && Input::has('skillTitle2')) {
             $skill2 = new Skill();
             $skill2->template_id = $template->id;
             $skill2->percent = Input::get('skillPercent2');
             $skill2->skill_title = Input::get('skillTitle2');
             if (Input::has('skillDescription2')) {
                 $skill2->description = Input::get('skillDescription2');
             }
             if (Input::has('skillDescriptionTitle2')) {
                 $skill2->description_title = Input::get('skillDescriptionTitle2');
             }
             if (Input::has('hobbies2')) {
                 $skill2->description_title = Input::get('hobbies2');
             }
             $skill2->save();
         }
         if (Input::has('skillPercent3') && Input::has('skillTitle3')) {
             $skill3 = new Skill();
             $skill3->template_id = $template->id;
             $skill3->percent = Input::get('skillPercent3');
             $skill3->skill_title = Input::get('skillTitle3');
             if (Input::has('skillDescription3')) {
                 $skill3->description = Input::get('skillDescription3');
             }
             if (Input::has('skillDescriptionTitle3')) {
                 $skill3->description_title = Input::get('skillDescriptionTitle3');
             }
             if (Input::has('hobbies3')) {
                 $skill3->description_title = Input::get('hobbies3');
             }
             $skill3->save();
         }
//.........这里部分代码省略.........
开发者ID:resumeproductions,项目名称:Resume-Solutions,代码行数:101,代码来源:TemplatesController.php

示例7: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if ($model->occupation->templ == 'members') {
         $model->scenario = 'genre';
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Users'])) {
         if ($_POST['member'] == 0) {
             $model->name = $_POST['Users']['name'];
             Yii::app()->user->name = $model->name;
             $model->gender = $_POST['Users']['gender'];
             $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             $model->birth_public = $_POST['Users']['birth_public'];
             $model->city_id = $_POST['Users']['city_id'];
             $model->email = $_POST['Users']['email'];
             $model->about = $_POST['Users']['about'];
             $model->phone = $_POST['Users']['phone'];
             $model->phone2 = $_POST['Users']['phone2'];
             $model->phone3 = $_POST['Users']['phone3'];
             if ($model->validate() && $model->save()) {
                 Yii::app()->user->setFlash('success_save', '1');
                 $this->redirect(array('index'));
             }
             /*else { 
                   echo CHtml::errorSummary($model);
                   //exit();
               }*/
         }
         if ($_POST['member'] == 1) {
             //$model->attributes=$_POST['Users'];
             if (isset($_POST['Users']['name_studio'])) {
                 $_POST['Users']['name'] = $_POST['Users']['name_studio'];
                 //unset($_POST['Users']['name_studio']);
                 $model->setScenario('studio_update');
             }
             foreach ($_POST['Users'] as $k => $v) {
                 if ($k == 'photo') {
                     if ($v != '') {
                         $model->photo = CUploadedFile::getInstance($model, 'photo');
                     }
                 } elseif ($k == 'url') {
                     $v = str_replace('http://', '', $v);
                     $model->{$k} = $v;
                 } else {
                     $model->{$k} = $v;
                 }
             }
             if (!isset($_POST['Users']['phone2'])) {
                 $model->phone2 = '';
             }
             if (!isset($_POST['Users']['phone3'])) {
                 $model->phone3 = '';
             }
             if (isset($_POST['year_b'])) {
                 $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             }
             Yii::app()->user->name = $model->name;
             //echo '<pre>';
             //print_r($_POST);
             //echo '</pre>';
             //exit();
             if (isset($_POST['Users']['genre_id'])) {
                 $model->genre_id = serialize($_POST['Users']['genre_id']);
             }
             if ($model->save()) {
                 if (isset($_POST['Users']['genre_id'])) {
                     Yii::import('application.modules.my.models.Portfolio');
                     Yii::import('application.modules.my.models.Video');
                     Yii::import('application.modules.my.models.Genre');
                     $keys = array();
                     $data = '';
                     $data = Portfolio::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
                     //print_r($data); exit();
                     if (is_array($data) && !empty($data)) {
                         //Portfolio::model()->deleteAllByAttributes(array('uid'=>Yii::app()->user->id));
                         //exit();
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $item = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'title' => Genre::getName($genre)));
                             if (count($item) > 0) {
                                 $keys[] = $item->id;
                             } else {
                                 $mod = new Portfolio();
                                 $mod->title = Genre::getName($genre);
                                 $mod->uid = Yii::app()->user->id;
                                 $mod->save();
                                 $keys[] = $mod->id;
                             }
                         }
                         $del = new Portfolio();
                         $criteria = new CDbCriteria();
                         $criteria->condition = 'uid=' . Yii::app()->user->id;
                         $criteria->addNotInCondition('id', $keys);
                         $del->deleteAll($criteria);
                     } else {
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $mod = new Portfolio();
                             $mod->title = Genre::getName($genre);
                             $mod->uid = Yii::app()->user->id;
//.........这里部分代码省略.........
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:101,代码来源:ProfileController.php

示例8: add

 public function add()
 {
     $path = "uploads/images/{$this->name}/";
     if (Request::isMethod('post')) {
         if (Request::ajax()) {
             $file = Input::file('image');
             $input = array('image' => $file);
             $rules = array('image' => 'image|max:3000');
             $validator = Validator::make($input, $rules);
             if ($validator->fails()) {
                 return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
             } else {
                 $file = Input::file('image');
                 $input = array('image' => $file);
                 $rules = array('image' => 'image|max:3000');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
                 } else {
                     $hash = md5(time());
                     $filename = "{$hash}.jpg";
                     $filenameThumb = "{$hash}_small.jpg";
                     Input::file('image')->move($path, $filename);
                     $img = Image::make($path . $filename);
                     $img->fit(100, 100);
                     $thumb = $path . $filenameThumb;
                     $img->save($thumb);
                     return Response::json(['success' => true, 'thumb' => asset($thumb), 'tmp' => $hash]);
                 }
             }
         }
         $rules = array('title' => 'required|min:4', 'link' => "required|unique:{$this->table}", 'description' => 'required|min:20|max:500', 'meta_keywords' => 'required', 'images' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $images = Input::get('images');
             return Redirect::to("admin/{$this->name}/add")->with('images', $images)->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new Portfolio();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->description = Input::get('description');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->active = Input::get('active', 0);
             $table->images = Input::get('images');
             if ($table->save()) {
                 $id = $table->id;
                 $images = explode(',', $table->images);
                 $imagesStr = '';
                 for ($i = 1; $i <= count($images); $i++) {
                     $num = $i - 1;
                     File::move($path . $images[$num] . '.jpg', "{$path}{$id}_{$i}.jpg");
                     File::move($path . $images[$num] . '_small.jpg', "{$path}{$id}_{$i}_small.jpg");
                     if ($i == count($images)) {
                         $imagesStr .= "{$id}_{$i}";
                     } else {
                         $imagesStr .= "{$id}_{$i},";
                     }
                 }
                 $table->images = $imagesStr;
                 if ($table->save()) {
                     $name = trans("name.{$this->name}");
                     return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
                 }
                 return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['name' => $this->name, 'action' => $this->action]);
 }
开发者ID:Rotron,项目名称:shop,代码行数:73,代码来源:AdminPortfolioController.php


注:本文中的Portfolio::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。