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


PHP Post::whereDelete_status方法代码示例

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


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

示例1: postEdit

 public function postEdit($id = null)
 {
     $check_post_active = Post::whereDelete_status(0)->whereId($id)->first();
     if ($check_post_active) {
         $data = Input::all();
         $validator = Post::validate($data);
         if ($validator->fails()) {
             return Redirect::to('admin/post/edit/' . $id)->withInput()->withErrors($validator);
         } else {
             $check_post_active->title = $data['title'];
             $check_post_active->content = $data['content'];
             $check_post_active->category_id = $data['category'];
             $destination_path = './public/images/post/';
             // upload path
             if (isset($data['remove_image'])) {
                 if ($check_post_active->image) {
                     if (File::exists($destination_path . $check_post_active->image)) {
                         File::delete($destination_path . $check_post_active->image);
                     }
                 }
                 $check_post_active->image = "";
             } else {
                 if (Input::file('image')) {
                     $extension = Input::file('image')->getClientOriginalExtension();
                     // getting image extension
                     $file_name = str_random(8) . '.' . $extension;
                     // renameing image
                     if (Input::file('image')->move($destination_path, $file_name)) {
                         if ($check_post_active->image != "" && File::exists($destination_path . $check_post_active->image)) {
                             File::delete($destination_path . $check_post_active->image);
                         }
                         $check_post_active->image = $file_name;
                     }
                 }
             }
             $check_post_active->save();
             Session::flash('edit_status', ['status' => 'success', 'message' => 'Edit post is success!']);
             return redirect()->back();
         }
     } else {
         return redirect('post/edit');
     }
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:43,代码来源:PostController.php

示例2: getPosts

 /**
  * Function manager posts
  * @author  Tran Van Moi
  * @since  2015/06/01
  * @return response
  */
 public function getPosts()
 {
     $data['posts'] = Post::whereDelete_status(0)->join('categories', 'posts.category_id', '=', 'categories.id')->select('posts.id', 'posts.title', 'posts.content', 'posts.image', 'posts.created_at', 'posts.updated_at', 'categories.name as category_name')->orderBy('posts.created_at', 'desc')->orderBy('posts.updated_at', 'desc')->get();
     return view('admin/post', $data);
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:11,代码来源:HomeController.php


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