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


PHP Category::getCategoriesByPublish方法代码示例

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


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

示例1: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $favicon = Settings::getSettings()['favicon'];
     $logo = Settings::getSettings()['logo'];
     $parent_categories = Category::getCategoriesByPublish(1, 0, 1);
     View::share('favicon', $favicon);
     View::share('logo', $logo);
     View::share('parent_categories', $parent_categories);
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:14,代码来源:AppServiceProvider.php

示例2: edit

 /**
  * Edit post
  *
  * @param Request $request
  * @param int $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function edit(Request $request, $id = 0)
 {
     $post = Post::getPostById($id);
     if (empty($post)) {
         return redirect()->back();
     } else {
         if ($request->isMethod("post")) {
             $rules = ["title" => "required", "alias" => "required|unique:posts,alias," . $id, "content" => "required", 'image' => 'mimes:jpeg,jpg,png'];
             Validator::make($request->all(), $rules)->validate();
             $post->title = $request->input("title");
             $post->alias = $request->input("alias");
             $post->content = $request->input("content");
             $post->meta_keys = $request->input("meta_keys");
             $post->meta_desc = $request->input("meta_desc");
             if (!empty($request->file("image"))) {
                 if (!empty($post->image)) {
                     if (Storage::exists('uploads/' . $post->image) && Storage::exists('uploads/fb-' . $post->image)) {
                         Storage::delete('uploads/' . $post->image, 'uploads/fb-' . $post->image);
                     }
                 }
                 $generated_string = str_random(32);
                 $file = $request->file("image")->store('uploads');
                 $new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension();
                 Storage::move($file, 'uploads/' . $new_file);
                 $img = Image::make($request->file('image'));
                 $img->crop(200, 200);
                 $img->save(storage_path('app/public/uploads/' . $new_file));
                 $img = Image::make($request->file('image'));
                 $img->resize(600, 315);
                 $img->save(storage_path('app/public/uploads/fb-' . $new_file));
                 $post->image = $new_file;
             }
             if ($request->has("category")) {
                 $post->category_id = $request->input("category");
             }
             $post->publish = $request->has("publish");
             $post->save();
             $new_tags = [];
             if ($request->has("tags")) {
                 $tags = $request->input("tags");
                 foreach ($tags as $tag) {
                     array_push($new_tags, $tag);
                 }
             }
             $post->tags()->sync($new_tags);
             return redirect()->route('posts');
         } else {
             $categories = Category::getCategoriesByPublish();
             $tags = Tag::getTags();
             return view("site.post.edit", compact("post", "categories", "tags"));
         }
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:60,代码来源:PostController.php


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