Example #1
0
 public static function updateBundle($postId, array $bundle)
 {
     $postmeta = PostMeta::where('post_id', $postId)->where('meta_key', $bundleKey)->first();
     if ($postmeta) {
         $postmeta->meta_value = $bundleValue;
         $postmeta->save();
     }
 }
Example #2
0
 public function destroy($id)
 {
     // remove specific post
     $post = Post::where('post_type', 'post')->where('id', $id)->first();
     // remove all post meta
     PostMeta::where('post_id', $post->id)->delete();
     // remove all post tags
     PostTag::where('post_id', $post->id)->delete();
     if ($post && $post->delete()) {
         return true;
     }
     return false;
 }
Example #3
0
 function _postMeta($postId, $key)
 {
     if (!$postId) {
         return;
     }
     // if the key has a json decoded string,
     // iterate each item and match it to the value.
     if (is_array($key)) {
         $meta = PostMeta::where('post_id', $postId)->where('meta_key', $key['meta_key'])->first();
         if (!$meta) {
             return;
         }
         $metaValueJsonDecode = json_decode($meta->meta_value);
         if (count($metaValueJsonDecode) > 0) {
             foreach ($metaValueJsonDecode as $itemKey => $itemValue) {
                 if ($key['meta_value'] == $itemKey) {
                     return $itemValue;
                 }
             }
         }
     }
     $meta = PostMeta::where('post_id', $postId)->where('meta_key', $key)->first();
     if (!$meta) {
         return;
     }
     return $meta->meta_value;
 }