本文整理汇总了PHP中app\models\Product::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::load方法的具体用法?PHP Product::load怎么用?PHP Product::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Product
的用法示例。
在下文中一共展示了Product::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if (isset($_POST['name']) && is_array($_POST['name'])) {
foreach ($_POST['name'] as $lang => $val) {
$model->setName($lang, $val);
}
}
if (isset($_POST['description']) && is_array($_POST['description'])) {
foreach ($_POST['description'] as $lang => $val) {
$model->setDescription($lang, $val);
}
}
if (isset($_POST['information']) && is_array($_POST['information'])) {
foreach ($_POST['information'] as $lang => $val) {
$model->setInformation($lang, $val);
}
}
$model->updateURLCode();
return $this->redirect(['update', 'id' => $model->id, 'panel' => 'images']);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例2: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: actionCreateProduct
/**
* Pjaxified version of ProductController actionCreate
* @return partial
*/
public function actionCreateProduct()
{
$model = new Product();
if (Yii::$app->request->isPjax) {
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model = new Product();
}
return $this->renderPartial('_product_edit', ['model' => $model]);
}
}
示例4: actionCreate
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list']);
} else {
$model->status = Product::STATUS_ENABLED;
return $this->render('create', ['model' => $model]);
}
}
示例5: actionCreate
/**
* @param $node
* @return string|\yii\web\Response
*/
public function actionCreate($node)
{
$model = new Product();
$model->loadDefaultValues();
$model->category_id = $node;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list', 'node' => $node]);
}
return $this->render('create', ['model' => $model]);
}
示例6: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post())) {
// var_dump($_POST);
$this->isUploaded($model);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例7: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$categories = Categories::find()->all();
// need this for dropDownList in views/product/_form.php
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'itemId' => $model->item_id]);
} else {
return $this->render('create', ['model' => $model, 'categories' => $categories]);
}
}
示例8: actionSearchProducts
public function actionSearchProducts()
{
$modelForm = new Product();
$results = null;
if ($modelForm->load(Yii::$app->request->post())) {
$results = $modelForm->giveAllProductsByName($modelForm->name);
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
} else {
return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
}
}
示例9: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$app = \Yii::$app;
$model = new Product();
$render = "render";
if ($app->request->isPjax || $app->request->isAjax) {
$render = "renderPartial";
}
if ($model->load($app->request->post()) && $model->save()) {
$model = new Product();
}
return $this->{$render}('form', ['model' => $model]);
}
示例10: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post())) {
$model->created_time = date("Y-m-d H:i:s");
$model->last_update = $model->created_time;
$model->user_id = \Yii::$app->user->id;
Util::save($model);
$model = new Product();
}
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('create', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例11: store
public function store(Request $request)
{
$input = $request->json()->all();
unset($input['categories']);
$product = new Product($input);
$product->save();
if (($categories = $request->json()->get('categories')) && !empty($categories)) {
if (is_string($categories)) {
$categories = explode(',', $categories);
}
$product->categories()->attach($categories);
}
$product->load('categories');
return response()->created($product);
}
示例12: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
$model_can_save = false;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->fileImage = \yii\web\UploadedFile::getInstance($model, 'fileImage');
if ($model->fileImage) {
$model->fileImage->saveAs(Yii::getAlias('@uploadedfilesdir'));
}
$model_can_save = true;
return $this->redirect(['view', 'id' => $model->product_id]);
} else {
return $this->render('create', ['model' => $model, 'model_can_save' => $model_can_save]);
}
}
示例13: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
$model->setScenario('create');
if ($model->load(Yii::$app->request->post())) {
$model->images = UploadedFile::getInstances($model, images);
$model->image = FileUploader::upload(UploadedFile::getInstance($model, 'image'), 'product', $model->image);
if ($model->validate()) {
if ($model->save()) {
return $this->redirect(['index']);
}
}
}
return $this->render('create', ['model' => $model]);
}
示例14: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
$model->scenario = 'create';
if ($model->load(Yii::$app->request->post())) {
$image1 = UploadedFile::getInstance($model, 'image1');
if ($image1 != NULL) {
$name1 = date('Y_m_d_H_i_s_') . $image1->baseName . '.' . $image1->extension;
$model->image1 = $name1;
}
$image2 = UploadedFile::getInstance($model, 'image2');
if ($image2 != NULL) {
$name2 = date('Y_m_d_H_i_s_') . $image2->baseName . '.' . $image2->extension;
$model->image2 = $name2;
}
$image3 = UploadedFile::getInstance($model, 'image3');
if ($image3 != NULL) {
$name3 = date('Y_m_d_H_i_s_') . $image3->baseName . '.' . $image3->extension;
$model->image3 = $name3;
}
if ($model->save()) {
if ($model->auction == "YES") {
$auction = new Auction();
$auction->product_id = $model->id;
$auction->value = $model->price;
$auction->save();
}
if ($image1 != NULL) {
$image1->saveAs('img/products/' . $name1);
}
if ($image2 != NULL) {
$image2->saveAs('img/products/' . $name2);
}
if ($image3 != NULL) {
$image3->saveAs('img/products/' . $name3);
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例15: actionCreate
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$this->checkLogin();
$this->layout = 'admin';
$model = new Product();
$modelType = new Type();
$allType = $modelType->getAllType();
if ($model->load(Yii::$app->request->post())) {
$model->image = UploadedFile::getInstances($model, 'image');
foreach ($model->image as $file) {
$file->saveAs('images/' . $file->baseName . '.' . $file->extension);
$images[] = $file->baseName . '.' . $file->extension;
}
$model->image = implode(',', $images);
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'allType' => $allType]);
}
}