public function setUp() { parent::setUp(); $this->product = Product::getNewInstance($this->rootCategory, 'test'); $this->product->save(); $this->group = ProductFileGroup::getNewInstance($this->product); $this->group->save(); // create temporary file file_put_contents($this->tmpFilePath, $this->fileBody); }
public function setUp() { parent::setUp(); // Create some product $this->product = Product::getNewInstance($this->rootCategory, 'test'); $this->product->save(); return; // create new group $dump = ProductRelationshipGroup::getNewInstance($this->product); $dump->save(); }
public function setUp() { parent::setUp(); $this->specField = SpecField::getNewInstance($this->rootCategory, SpecField::DATATYPE_TEXT, SpecField::TYPE_TEXT_SELECTOR); $this->specField->save(); $this->specFieldAutoIncrementNumber = $this->specField->getID(); $specFieldValue = SpecFieldValue::getNewInstance($this->specField); $specFieldValue->save(); $this->specFieldValueAutoIncrementNumber = $specFieldValue->getID(); $this->product = Product::getNewInstance($this->rootCategory, 'test'); $this->product->save(); $this->productAutoIncrementNumber = $this->product->getID(); }
public function getAdminInterface() { $st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name"; $products = Database::singleton()->query_fetch_all($st); $formPath = "/admin/EComm§ion=Plugins&page=ChangeProductPrice"; $form = new Form('change_product_prices', 'post', $formPath); if ($form->validate() && isset($_REQUEST['submit'])) { foreach ($products as $product) { $ECommProduct = new Product($product['product_id']); $ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]); $ECommProduct->save(); } return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>"; } $oldSupplier = 0; $currentSupplier = 0; $defaultValue = array(); foreach ($products as $product) { $currentSupplier = $product['supplier_id']; if ($oldSupplier != $currentSupplier) { $form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>'); } $form->addElement('text', 'product_' . $product['product_id'], $product['product_name']); $defaultValue['product_' . $product['product_id']] = $product['product_price']; $oldSupplier = $product['supplier_id']; } $form->addElement('submit', 'submit', 'Submit'); $form->setDefaults($defaultValue); return $form->display(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // // create the validation rules ------------------------ $rules = array('name' => 'required', 'descrption' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { // get the error messages from the validator $messages = $validator->messages(); // redirect our user back to the form with the errors from the validator return Redirect::route('product.create')->withErrors($validator); } else { if (Input::hasFile('image')) { foreach (Input::file('image') as $image) { $imagename = time() . $image->getClientOriginalName(); $uploadflag = $image->move('uploads', $imagename); if ($uploadflag) { $uploadedimages[] = $imagename; } } $name = Input::get('name'); $description = Input::get('descrption'); $product = new Product(); $product->name = $name; $product->productdes = $description; $product->images = json_encode($uploadedimages); $product->save(); return Redirect::route('product.index'); } else { return Redirect::route('product.create')->withErrors('product image needed'); } } //end else }
public function postCreate() { $validator = Validator::make(Input::all(), Product::$rules); if ($validator->passes()) { $product = new Product(); $product->category_id = Input::get('category_id'); $product->title = Input::get('title'); $product->description = Input::get('description'); $product->price = Input::get('price'); // $image = Input::file('image'); // // $filename = date('Y-m-d-H:i:s')."-". $image->getClientOriginalName(); // $filename = time() . '.' . $image->getClientOriginalExtension(); // $product->image = 'img/products/'. $filename; // // $path = public_path('img/products/' . $filename); // $product->save(); // Image::make($image->getRealPath())->resize(468, 249)->save('/img/products/'. $filename); $file = Input::file('image'); $orig_name = str_random(6) . $file->getClientOriginalName(); $dest_path = public_path() . "/img/products/"; $upload = $file->move($dest_path, $orig_name); $product->image = "/img/products/" . $orig_name; $product->save(); return Redirect::to('admin/products/index')->with('message', 'Product Created'); } return Redirect::to('admin/products/index')->with('message', 'Something went wrong')->withErrors($validator)->withInput(); }
/** * Add product */ public function addProduct() { if (Auth::check()) { $validator = Validator::make(Input::all(), array('name' => 'required', 'price' => 'required', 'description' => 'required', 'condition' => 'required', 'quantity' => 'required', 'brand' => 'required', 'image' => 'required|image|mimes:jpg,jpeg,png|max:6000', 'point' => 'required', 'product_code' => 'required|unique:products')); if ($validator->fails()) { return Redirect::route('add-product-page')->withErrors($validator)->withInput(); } else { $file = Input::file('image'); $file_name = date('d-m-Y-h-i-s-') . $file->getClientOriginalName(); $destination = $destination = "assets/images/shop/"; $file->move($destination, $file_name); $product = new Product(); $product->name = Input::get('name'); $product->slug = Str::slug(Input::get('name')); $product->price = Input::get('price'); $product->description = Input::get('description'); $product->catagory_id = Input::get('catagory'); $product->subcatagory_id = Input::get('subcatagory'); $product->quantity = Input::get('quantity'); $product->product_condition = Input::get('condition'); $product->brand = Input::get('brand'); $product->image = $file_name; $product->point = Input::get('point'); $product->product_code = Input::get('product_code'); $product->code = uniqid(str_random(9)); if ($product->save()) { return Redirect::back()->with("event", '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Product saved successfully.</p>'); } return Redirect::back()->with("event", '<p class="alert alert-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> Error occured. Please try after sometime</p>'); } } else { return Redirect::route('admin-login')->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> You are not loged in!</p>'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // se define la validacion de los campos $rules = array('category_id' => 'array', 'name' => 'required|max:60', 'value' => 'numeric|required', 'cost' => 'numeric|required', 'enable' => 'in:SI,NO'); // Se validan los datos ingresados segun las reglas definidas $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $product = new Product(); if (Input::get('category_id')) { $product->category_id = Input::get('category_id'); } if (Input::get('name')) { $product->name = Input::get('name'); } if (Input::get('description')) { $product->description = Input::get('description'); } if (Input::get('value')) { $product->value = Input::get('value'); } if (Input::get('cost')) { $product->cost = Input::get('cost'); } if (Input::get('enable')) { $product->enable = Input::get('enable'); } $product->save(); return Redirect::to('admin/product')->with('success_message', 'El registro ha sido ingresado correctamente.')->withInput(); }
public function saveProduct() { $data = Input::all(); if (!Auth::guest()) { $validator = Validator::make($data, Product::$rules); if ($validator->passes()) { $user = Auth::user(); $product = new Product(); $product->user_id = $user->id; $product->product_name = $data['product_name']; $product->description = $data['description']; $product->start_price = $data['start_price']; $product->save(); if (isset($data['categories']) && !empty($data['categories'])) { $product->categories()->attach($data['categories']); } if (Session::has('files')) { $files = Session::get('files'); // get session files foreach ($files as $key => $file) { $directory_file = public_path() . '/product_images/' . $file; if (File::exists($directory_file)) { File::move($directory_file, public_path() . '/product_images/product_' . $product->id . '_' . $key . '.jpg'); } } Session::forget('files'); } return Response::json(array('success' => true, 'product' => $product)); } return Response::json(array('success' => false, 'type' => 'form_error', 'errors' => $validator->messages())); } return Response::json(array('success' => false, 'type' => 'log_error', 'error' => 'In order to save your product, please, log in!')); }
public function postCreate() { $validator = Validator::make(Input::all(), Product::$rules); if ($validator->passes()) { $product = new Product(); $product->title = Input::get('title'); $product->description = Input::get('description'); $id = Input::get('product_id'); $skuAsset = sprintf("%06s", $id); $product->sku = 'INDE' . $skuAsset; $product->category_id = Input::get('category_id'); $product->subcategory_id = Input::get('subcategory_id'); $product->price = Input::get('price'); $product->weight = Input::get('weight'); $product->supplier_id = Auth::user()->id; $product->image = 'images/products/INDE' . $skuAsset; $product->save(); $details = new Detail(); $details->details = Input::get('details'); $details->model = Input::get('model'); $details->brand = Input::get('brand'); $details->moredescription = Input::get('moredescription'); $details->product_id = Input::get('product_id'); $details->save(); return Response::json('success', 200); } else { return $validator->errors; } }
public function store() { $rules = array('code' => 'required', 'name' => 'required', 'mark' => 'required', 'price' => array('required', 'regex:/^\\d*(\\.\\d{2})?$/'), 'categories' => 'required', 'product_image' => 'mimes:jpeg,bmp,png'); $validator = Validator::make(Input::all(), $rules); // process the login if ($validator->fails()) { return Redirect::to('admin/product/create')->withErrors($validator)->withInput(); } else { // store $filename = ""; if (Input::hasFile('product_image')) { if (Input::file('product_image')->isValid()) { Input::file('product_image')->move(ProductController::imagePath()); $filename = Input::file('product_image')->getClientOriginalName(); } } $product = new Product(); $product->code = Input::get('code'); $product->mark = Input::get('mark'); $product->name = Input::get('name'); if ($filename !== "") { $product->image = ProductController::imagePath() . $filename; } $product->price = Input::get('price'); $product->save(); foreach (Input::get('categories') as $catId) { DB::table('products_category')->insert(array('product_id' => Input::get('code'), 'category_id' => $catId)); } // redirect Session::flash('message', 'Successfully created product!'); return Redirect::to('admin/product'); } }
/** * Validates data submitted in the add form. If the validation fails, * displays the add page. Otherwise, creates a new product, saves it and * its ingredients to the database and redirects to the add page. */ public static function add() { $params = $_POST; $attributes = array('product_name' => $params['product_name'], 'price' => $params['price'], 'category' => $params['category'], 'description' => $params['description']); if (isset($params['customizable'])) { $attributes['customizable'] = 'TRUE'; } else { $attributes['customizable'] = 'FALSE'; } if (isset($params['ingredients'])) { $attributes['ingredients'] = $params['ingredients']; } $validator = self::product_validator($attributes); if ($validator->validate()) { $product = new Product($attributes); $product->save(); if (isset($params['ingredients'])) { self::set_product_ingredients($product, $params['ingredients']); } Redirect::to($params['redirect'], array('message' => 'Tuote lisätty!')); } else { $ingredients = Ingredient::findByCategory($attributes['category']); View::make('product/add.html', array('ingredients' => $ingredients, 'errors' => $validator->errors(), 'product' => $attributes)); } }
protected function setUp() { $firstProduct = new Product(); $firstProduct->name = "wooden chair 2x"; $firstProduct->description = "a wooden chair made of wood"; $firstProduct->quantity = 50; $firstProduct->price = 3000; $firstProduct->sku = uniqid(); if (!$firstProduct->save()) { throw new Exception(CHtml::errorSummary($firstProduct)); } else { $this->productModels[] = $firstProduct; } $secondProduct = new Product(); $secondProduct->name = "wooden chair 3x"; $secondProduct->description = "a wooden chair made of wood but with color"; $secondProduct->quantity = 60; $secondProduct->price = 4000; $secondProduct->sku = uniqid(); if (!$secondProduct->save()) { throw new Exception(CHtml::errorSummary($secondProduct)); } else { $this->productModels[] = $secondProduct; } /*create product model*/ parent::setUp(); }
public function actionUpload_product() { if (Yii::$app->request->isAjax) { $model = new ProductCategory(); $Product = new Product(); $ProductImageRel = new ProductImageRel(); $ProductCategoryRel = new ProductCategoryRel(); $model_cat_title = UploadedFile::getInstance($model, 'cat_title'); $time = time(); $model_cat_title->saveAs('product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension); if ($model_cat_title) { $response = []; $Product->title = $_POST['title']; $Product->desc = $_POST['desc']; $Product->status = 1; if ($Product->save()) { $ProductCategoryRel->category_id = $_POST['id']; $ProductCategoryRel->product_id = $Product->id; $ProductImageRel->product_id = $Product->id; $ProductImageRel->image = $time . $model_cat_title->baseName . '.' . $model_cat_title->extension; if ($ProductCategoryRel->save() && $ProductImageRel->save()) { $response['files'][] = ['name' => $time . $model_cat_title->name, 'type' => $model_cat_title->type, 'size' => $model_cat_title->size, 'url' => Url::base() . '/product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension, 'deleteUrl' => Url::to(['delete_uploaded_file', 'file' => $model_cat_title->baseName . '.' . $model_cat_title->extension]), 'deleteType' => 'DELETE']; $response['base'] = $time . $model_cat_title->baseName; $response['view'] = $this->renderAjax('uploaded_product', ['url' => Url::base() . '/product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension, 'basename' => $time . $model_cat_title->baseName, 'id' => $ProductImageRel->id, 'model' => $Product]); } } else { $response['errors'] = $product->getErrors(); } return json_encode($response); } } }
public function post() { $post = Input::all(); $validator = Product::validate($post); $productId = $post['id']; if ($validator->fails()) { return Redirect::to('productos/' . $productId)->withErrors($validator)->withInput(); } else { $product = self::__checkExistence($productId); $isNew = false; if (!$productId) { $product = new Product(); $isNew = true; } $product->name = $post['name']; $product->description = $post['description']; $product->code = $post['code']; $product->minimum_stock = $post['minimum_stock']; $product->cost = str_replace(',', '.', $post['cost']); $product->save(); if ($isNew) { Globals::triggerAlerts(4, array('productId' => $product->id)); } if ($post['status'] == 'inactive') { $product->delete(); } else { if ($product->trashed()) { $product->restore(); } } Session::flash('success', 'Producto guardado correctamente.'); return Redirect::to('productos'); } }
public function actionCreate() { $model = new Product(); $model->dpid = $this->companyId; //$model->create_time = time(); if (Yii::app()->request->isPostRequest) { $model->attributes = Yii::app()->request->getPost('Product'); $se = new Sequence("product"); $model->lid = $se->nextval(); $model->create_at = date('Y-m-d H:i:s', time()); $model->update_at = date('Y-m-d H:i:s', time()); $model->delete_flag = '0'; $py = new Pinyin(); $model->simple_code = $py->py($model->product_name); //var_dump($model);exit; if ($model->save()) { Yii::app()->user->setFlash('success', yii::t('app', '添加成功!')); $this->redirect(array('product/index', 'companyId' => $this->companyId)); } } $categories = $this->getCategoryList(); //$departments = $this->getDepartments(); //echo 'ss';exit; $this->render('create', array('model' => $model, 'categories' => $categories)); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aProduct !== null) { if ($this->aProduct->isModified() || $this->aProduct->getCulture() && $this->aProduct->getCurrentTranslation()->isModified() || $this->aProduct->isNew()) { $affectedRows += $this->aProduct->save($con); } $this->setProduct($this->aProduct); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ProductI18nPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setNew(false); } else { $affectedRows += ProductI18nPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Post Add Product */ public function postNewProduct() { $rules = array('name' => 'required', 'code' => 'required|unique:products', 'type' => 'required', 'has_license' => 'numeric', 'logo_url' => 'required|url', 'landing_url' => 'required|url', 'aweber_list_id' => '', 'ipn_url' => 'url', 'api_url' => 'required|url', 'api_key' => '', 'head_code' => '', 'body_code' => ''); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('admin/products/new-product')->withErrors($validator)->withInput(); } else { $product = new Product(); $product->name = Input::get('name'); $product->code = Input::get('code'); $product->type = Input::get('type'); $product->has_license = Input::get('has_license') ? 1 : 0; $product->logo_url = Input::get('logo_url'); $product->landing_url = Input::get('landing_url'); $product->aweber_list_id = Input::get('aweber_list_id'); $product->ipn_url = Input::get('ipn_url'); $product->api_url = Input::get('api_url'); $product->api_key = Input::get('api_key'); $product->head_code = Input::get('head_code'); $product->body_code = Input::get('body_code'); $product->save(); Session::flash('alert_message', '<strong>Well done!</strong> You successfully have added new product.'); return Redirect::to('admin/products'); } }
public function setUp() { parent::setUp(); // Create some product $this->product1 = Product::getNewInstance($this->rootCategory, 'test'); $this->product1->save(); $this->productAutoIncrementNumber = $this->product1->getID(); // Create second product $this->product2 = Product::getNewInstance($this->rootCategory, 'test'); $this->product2->save(); // create new group $this->group = ProductRelationshipGroup::getNewInstance($this->product1, ProductRelationship::TYPE_CROSS); $this->group->position->set(5); $this->group->save(); $this->groupAutoIncrementNumber = $this->group->getID(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Product(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Product'])) { $model->attributes = $_POST['Product']; $imgName = str_replace("/productimg/", "", $model->pic); $model->pic = $imgName; if (count($model->per100g)) { foreach ($model->per100g as $name => $value) { if (!$value['label'] && !$value['value']) { continue; } $per100g[$name] = $value; } $model->per100g = json_encode($model->per100g); } if (count($model->allergies)) { $model->allergies = implode(',', $model->allergies); } if (count($model->ingredients)) { $model->ingredients = implode(',', $model->ingredients); } if ($model->save()) { $this->redirect(array('product/admin')); } $model->per100g = null; $model->allergies = null; $model->ingredients = null; } $this->render('create', array('model' => $model)); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aProduct !== null) { if ($this->aProduct->isModified() || $this->aProduct->isNew()) { $affectedRows += $this->aProduct->save($con); } $this->setProduct($this->aProduct); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
public function create() { $model = new Product(); $model->url = "url-" . time(); $model->title = ""; $model->status = 3; $this->redirect_to("/admin/products/edit/" . $model->save()->id . "/"); }
/** @test */ public function it_should_upload_single_media() { config()->set('medias.models', ['products' => ['model' => 'Product', 'fields' => ['cover']]]); $product = new Product(); $product->id = 1; $product->uploadSingleMedia($this->getPicture(), 'cover'); $product->save(); $this->assertNotNull(Product::find(1)->cover); }
function __construct() { adminGateKeeper(); \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey()); $container_guid = getInput("container_guid"); $title = getInput("title"); $description = getInput('description'); $interval = getInput("interval"); $price = getInput("price"); $product = new Product(); $product->title = $title; $product->description = $description; $product->price = $price; $product->container_guid = $container_guid; $product->interval = $interval; $product->access_id = "public"; $product->save(); $product->createAvatar(); if (isset($_FILES["download"]) && $_FILES["download"]["name"]) { $file = new File(); $file->access_id = "product"; $file->container_guid = $product->guid; $guid = $file->save(); uploadFile("download", $guid, array("zip")); $product->download = $guid; } if ($interval != "one_time") { $stripe_plan = \Stripe\Plan::create(array("amount" => $price * 100, "interval" => $interval, "name" => $title, "currency" => "usd", "id" => $product->guid)); $id = $stripe_plan->id; $product->stripe_id = $id; $product->save(); } else { // Create product and SKU in stripe $stripe_product = \Stripe\Product::create(array("name" => $product->title, "description" => $product->description, "shippable" => false)); $product->stripe_product_id = $stripe_product->id; // Create SKU $stripe_sku = \Stripe\SKU::create(array("product" => $stripe_product->id, "price" => $product->price * 100, "currency" => "usd", "inventory" => array("type" => "infinite"), "metadata" => array("guid" => $product->guid))); $product->stripe_sku = $stripe_sku->id; $product->save(); } new SystemMessage("Your product has been saved."); forward("store"); }
public function actionSaveProduct() { if (!empty($_POST)) { $model = new Product(); $model->attributes = $_POST["Product"]; if ($model->save()) { echo "success"; } } }
public function postCreate() { $posted = Input::all(); $product = new Product(); $product->product_name = $posted['product_name']; $product->category_id = $posted['category_id']; $product->description = $posted['description']; $product->save(); return Redirect::back()->with('success', 'Product has been successfully created'); }
/** * @title("Create") * @description("Create a new product") * @response("Product object or Error object") * @requestExample({ * "title": "Title", * "brand": "Brand name", * "color": "green", * "createdAt": "1427646703000", * "updatedAt": "1427646703000" * }) * @responseExample({ * "product": { * "id": 144, * "title": "Title", * "brand": "Brand name", * "color": "green", * "createdAt": "1427646703000", * "updatedAt": "1427646703000" * } * }) */ public function create() { $data = $this->request->getJsonRawBody(); $product = new Product(); $product->assign((array) $data); if (!$product->save()) { throw new UserException(ErrorCodes::DATA_FAIL, 'Could not create product.'); } return $this->respondItem($product, new ProductTransformer(), 'product'); }
public function testSaving() { $object = \Product::loadOne(1); $this->assertEquals('Test', $object->title, 'Object has new title after loading'); $object = new \Product(); $this->assertTrue($object->isNew(), 'Newly created object returns isNew true'); $object->mergeWithData(array('title' => 'ipad', 'id_brand' => 1)); $object->save(); $this->assertEquals(array('id' => 2, 'title' => 'ipad', 'id_brand' => 1), $object->getArray(), 'Newly created object merged and saved'); }
public function postAdd() { $validation = Validator::make(Input::all(), Product::$validation); $validation_message = $validation->messages(); if ($validation->fails()) { return Redirect::back()->with(['message' => 'true', 'title' => 'Uyarı!', 'text' => 'Ürün başlığı veya ürün fiyat alanını boş bıraktınız. Lütfen tüm alanların doldurunuz.', 'type' => 'warning']); } $add = new Product(); $add->user = Auth::user()->id; $add->type = Input::get('type'); $add->title = Input::get('title'); $add->price = Input::get('price'); $add->save(); if ($add->save()) { return Redirect::to('product')->with(['message' => 'true', 'title' => 'Tebrikler!', 'text' => 'Ürün kaydı başarıyla oluşturuldu.', 'type' => 'success']); } else { return Redirect::back()->with(['message' => 'true', 'title' => 'Hata!', 'text' => 'Ürün kaydı oluşturulamadı! Lütfen daha sonra tekrar deneyiniz.', 'type' => 'error']); } }
public function testCreation() { $product = new \Product(); $product->info = array('test'); $this->assertEquals(array('test'), $product->getInfo(), 'Test before saving'); $product->save(); $this->assertEquals(array('test'), $product->getInfo(), 'Test after saving'); $product = \Product::loadOne(2); $this->assertEquals(array('test'), $product->getInfo(), 'Test after loading'); $this->assertTrue(is_array($product->info)); }