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


PHP Catalog::save方法代码示例

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


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

示例1: actionCreate

 /**
  * 添加栏目
  *
  */
 public function actionCreate()
 {
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach'], 'image', true);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $upload->deleteFile($upload->_thumb_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->attach_thumb = $upload->_thumb_name;
         }
         $now = time();
         $model->create_time = $now;
         $model->update_time = $now;
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $parentId = intval($_GET['id']);
     $this->render('create', array('model' => $model, 'parentId' => $parentId));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:31,代码来源:CatalogController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $inputs = Input::all();
     $catalog = new Catalog();
     $catalog->title = $inputs['title'];
     $catalog->description = $inputs['description'];
     $catalog->user_id = Auth::user()->id;
     $catalog->save();
     $car = new Car();
     $car->brand = $inputs['brand'];
     $car->engine = $inputs['engine'];
     $car->make = $inputs['make'];
     $car->milage = $inputs['milage'];
     $car->type = $inputs['type'];
     $car->transmission = $inputs['transmission'];
     $car->status = $inputs['status'];
     $car->location = $inputs['location'];
     $car->price = $inputs['price'];
     $car->youtube = $inputs['youtube'];
     $car->main_pic = 0;
     $car->user_id = Auth::user()->id;
     $car->catalog_id = $catalog->id;
     $car->save();
     $pictures = $inputs['pictures'];
     Log::info(user_photo_path() . $catalog->id . '/');
     if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) {
         File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true);
     }
     if (Input::hasFile('pictures[]')) {
         foreach ($pictures as $picture) {
             if ($picture != null) {
                 $image = Image::make($picture->getRealPath());
                 $fileName = str_replace(' ', '_', strrolower($picture->getClientOriginalName()));
                 $image->resize(1024, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName);
                 $pic = new Pictures();
                 $pic->url = $fileName;
                 $pic->user_id = Auth::user()->id;
                 $pic->catalog_id = $catalog->id;
                 $pic->type = 'catalog';
                 $pic->save();
             }
         }
     }
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_created'));
 }
开发者ID:stefferd,项目名称:autogarageooij,代码行数:58,代码来源:CatalogController.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Catalog();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:kibercoder,项目名称:dipstart-development,代码行数:17,代码来源:CatalogController.php

示例4: run

 public function run()
 {
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $now = time();
         $model->create_time = $now;
         $model->update_time = $now;
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $parentId = intval(Yii::app()->request->getParam('id'));
     $this->controller->render('create', array('model' => $model, 'parentId' => $parentId));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:15,代码来源:CreateAction.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $inputs = Input::all();
     $catalog = new Catalog();
     $catalog->title = $inputs['title'];
     $catalog->description = $inputs['description'];
     $catalog->user_id = Auth::user()->id;
     $catalog->save();
     $project = new Project();
     $project->role = $inputs['role'];
     $project->customer = $inputs['customer'];
     $project->location = $inputs['location'];
     $project->start = $inputs['start-month'] . '-' . $inputs['start-year'];
     $project->end = isset($inputs['not-ended']) && $inputs['not-ended'] ? 'present' : $inputs['end-month'] . '-' . $inputs['end-year'];
     $project->catalog_id = $catalog->id;
     $project->user_id = Auth::user()->id;
     $project->save();
     $pictures = $inputs['pictures'];
     Log::info(user_photo_path() . $catalog->id . '/');
     if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) {
         File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true);
     }
     if (Input::hasFile('pictures[]')) {
         foreach ($pictures as $picture) {
             if ($picture != null) {
                 $image = Image::make($picture->getRealPath());
                 $fileName = str_replace(' ', '_', $picture->getClientOriginalName());
                 $image->resize(1024, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName);
                 $pic = new Pictures();
                 $pic->url = $fileName;
                 $pic->user_id = Auth::user()->id;
                 $pic->catalog_id = $catalog->id;
                 $pic->type = 'catalog';
                 $pic->save();
             }
         }
     }
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_created'));
 }
开发者ID:stefferd,项目名称:autogarageooij,代码行数:52,代码来源:CatalogProjectController.php

示例6: actionCreate

 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl('catalog_create');
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入类别,ID:' . $model->id . '名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:22,代码来源:CatalogController.php

示例7: actionCreate

 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     //        parent::_acl();
     //        ppr($this->_catalogAll,1);
     parent::_acl();
     $model = new Catalog();
     //若有选择父分类的
     $parentId = reqGet('fid');
     if (!empty($parentId)) {
         $model->attributes = array('parent_id' => (int) $parentId);
     }
     $catalogAll = reqPost('Catalog');
     if (!empty($catalogAll)) {
         $catalogAll['create_time'] = $this->_thetime;
         //先判断是外链图片还是本地图片
         $imgtype = reqPost('imgtype', null);
         //ppr($_POST,1);
         if (!empty($imgtype)) {
             if ($imgtype == 'local') {
                 $catalogAll['image_link'] = $this->_doLocalImage('image_link');
             }
             if (empty($catalogAll['image_link'])) {
                 $catalogAll['image_link'] = null;
             }
         }
         $model->attributes = $catalogAll;
         //            ppr($catalogAll,1);
         unset($catalogAll);
         if ($model->save()) {
             XXcache::refresh('_catalog');
             XXcache::refresh('_catalogAll');
             parent::_backendLogger(array('catalog' => 'create', 'intro' => '录入全局分类,父分类ID:' . $model->parent_id . '名称:' . $model->catalog_name));
             $fid = $this->_getParentCatalogId($model->parent_id);
             $this->redirect(array('index', 'fid' => $fid));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:lp19851119,项目名称:114la,代码行数:42,代码来源:CatalogController.php

示例8: actionCreate

 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(100, 150)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入全局分类,ID:' . $id . '名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $parentId = intval($this->_gets->getParam('id'));
     $model->template_list = 'list_text';
     $model->template_page = 'list_page';
     $model->template_show = 'show_post';
     $this->render('create', array('model' => $model, 'parentId' => $parentId));
 }
开发者ID:bigbol,项目名称:ziiwo,代码行数:27,代码来源:CatalogController.php

示例9: actionCatalogAdd

 /**
  * 添加 文件编目
  */
 function actionCatalogAdd()
 {
     $this->_pathway->addStep('添加文件编目信息');
     $id = $this->_context->id;
     if ($id == 1) {
         return "{msg:'不能添加到根'}";
     }
     $form = new Form_Catalog(url('admin::dictmanager/catalogAdd'));
     $form->add(QForm::ELEMENT, 'parent_id', array('_ui' => 'hidden', 'value' => $id));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             $catalog = new Catalog($form->values());
             $catalog->save();
             return "{id:'{$catalog->parent_id}', msg:'添加成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     }
     $this->_view['form'] = $form;
     $this->_viewname = 'catalogedit';
 }
开发者ID:Debenson,项目名称:openwan,代码行数:24,代码来源:dictmanager_controller.php


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