本文整理汇总了PHP中app\models\Categories::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::save方法的具体用法?PHP Categories::save怎么用?PHP Categories::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($request->cID) {
$category = Categories::where("cID", $request->cID)->first();
} else {
$category = new Categories();
}
$category->cName = $request->cName;
$category->cDescription = $request->cDes;
$category->cParentID = $request->categoryParent;
$category->cIsActive = is_null($request->active) ? 0 : 1;
$file = Input::file('image');
if (!is_null($file)) {
$destinationPath = public_path() . '/assets/images/';
$fileName = explode(".", $file->getClientOriginalName())[0];
$fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
Input::file('image')->move($destinationPath, $fileName);
$category->cIcon = $fileName;
if ($request->cID) {
//remove file name before
}
}
$category->save();
return Redirect::action('admin\\category@index');
/* https://laracasts.com/discuss/channels/general-discussion/laravel-5-image-upload-and-resize?page=1
* Link upload and resize image
*/
}
示例2: actionCategory
public function actionCategory()
{
for ($i = 1; $i <= 10; $i++) {
$model = new Categories();
$model->attributes = ['name' => 'Danh Mục Số ' . $i, 'title' => 'Title cua danh muc so ' . $i, 'slug' => 'danh-muc-so-' . $i, 'images' => '3.png', 'created_at' => time(), 'updated_at' => time()];
$model->save();
}
}
示例3: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Categories();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'alias' => $model->slugUrl]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: save_category
public function save_category(Request $request)
{
$category = new Categories();
$category->category_name = $request->category_name;
$category->category_description = $request->category_description;
$category->publication_status = $request->publication_status;
$category->save();
Session::put('message', 'Save Category Information Successfully !');
return redirect('/add-category');
}
示例5: actionCreate
/** Создание нового раздела
*/
public function actionCreate($cat_id = 0)
{
$model = new Categories();
$model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => 'gallery']);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect([$model->handler . '/list', 'id' => $model->id]);
} else {
$model->parent_id = $cat_id;
return $this->render('create', ['model' => $model]);
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|unique:categories']);
$category = new Categories();
$category->name = $request->input('name');
$category->slug = str_slug($request->input('name'));
$category->cover = null;
$category->description = $request->input('description');
$category->save();
return redirect()->route('admin.categories.index')->with('success', 'Successfully created!');
}
示例7: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($categoryId = null)
{
$categories = Categories::find()->all();
$model = new Categories();
$model->parent_category_id = $categoryId;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'categoryId' => $model->category_id]);
} else {
return $this->render('create', ['model' => $model, 'categories' => $categories]);
}
}
示例8: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Categories();
$model->active = true;
$model->updated_at = date("Y-m-d H:i:s");
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例9: actionCreate
/**
* Creates a new Resources model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id)
{
if ($id == 0) {
throw new \yii\web\BadRequestHttpException("Неправильный запрос");
}
$model = new Categories();
$model->parent_id = $id;
$model->handler = $this->id;
$model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list', 'id' => $model->parent_id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validation = Validator::make(Input::all(), $this->CreateRules);
if ($validation->fails()) {
if ($categoryFind = Categories::where('name', '=', Input::get('name'))->count()) {
return Redirect::back()->withErrors($validation)->withInput();
}
return Redirect::back()->withErrors($validation)->withInput();
}
if ($validation->passes()) {
$category = new Categories();
$category->name = Input::get('name');
if ($category->save()) {
return Redirect::intended('admin/categories')->with('message', sprintf(trans('message.msg_category_create_success'), $category->name));
}
return Redirect::intended('admin/categories')->withErrors(array('errors' => sprintf(trans('message.msg_category_update_fail'), Input::get('name'))));
}
return Redirect::back()->with('warning', trans('message.msg_category_input_error'))->withErrors($validation)->withInput();
}
示例11: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new Categories();
$indicatorsAvailable = IndicatorNames::find()->select(['name', 'id'])->indexBy('id')->column();
$indicatorsPresent = [];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
foreach (Yii::$app->request->post()['Categories']['indicators'] as $id_indicator) {
$catInd = new CategoriesIndicators();
$catInd->id_indicator_names = $id_indicator;
$catInd->id_categories = $model->id;
$catInd->save();
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'indicatorsAvailable' => $indicatorsAvailable, 'indicatorsPresent' => $indicatorsPresent]);
}
}