示例#1
0
文件: Posts.php 项目: koyeo/bichon
 public static function put($post)
 {
     $row = Posts::find($post['id']);
     if ($row && isset($post['alias']) && $row->alias == $post['alias']) {
         unset($post['alias']);
     }
     $validator = self::check($post);
     if ($validator->fails()) {
         return error(900, ['validateError' => $validator->messages()]);
     }
     return $row->update($post);
 }
示例#2
0
 protected function dealMulti(Request $request)
 {
     if ($request->input('table_submit') == 'multi' && $request->input('selected')) {
         $postCtr = new Postctr();
         $info = false;
         if ($request->input('multi') == 'draft') {
             foreach ($request->input('selected') as $key => $value) {
                 Posts::find($value)->update(['status' => 'public']);
                 $info = true;
             }
         }
         if ($request->input('multi') == 'public') {
             foreach ($request->input('selected') as $key => $value) {
                 Posts::find($value)->update(['status' => 'public']);
                 $info = true;
             }
         }
         if ($request->input('multi') == 'delete') {
             foreach ($request->input('selected') as $key => $value) {
                 Posts::find($value)->forceDelete();
                 $info = true;
             }
         }
         if ($info) {
             $page = $request->input('page');
             $request->replace(['success' => '批量操作成功']);
             $request->flash();
             return redirect('/admin/post/posts?page=' . $page);
         } else {
             $request->replace([]);
             $request->flash();
         }
     }
     return false;
 }