protected function retrieveConfigPostMetas($post, $postTypeModel)
	{
		$metaKeys = [];
		$metaTaxonomies = [];

		$allKeys = $this->getValidationsKeys($postTypeModel);
		foreach($allKeys as $key => $value){

			$customFieldObject = $this->getCustomFieldObject($postTypeModel, $key);

			if(isset($customFieldObject['type']) && $customFieldObject['type'] == 'taxonomy'){

				// We need to get the values from the taxonomy table
				if(array_key_exists('post_type', $customFieldObject)){

					$customfieldPostTypes = $this->getPostTypeIdentifiers($customFieldObject['post_type']);

					// Lets query the post to retrieve all the connected ids
					$taxonomyIds = $post->taxonomies()->whereIn('post_type', $customfieldPostTypes)
						->get();

					// Lets foreach all the posts because we only need the id
					$ids = [];
					foreach($taxonomyIds as $value){
						array_push($ids, $value->id);
					}

					$ids = json_encode($ids);

					$metaTaxonomies[$key] = [
						'meta_key' => $key,
						'meta_value' => $ids,
					];

				}

			// The other items are default
			} else {

				// Register it to the main array so we can query it later
				array_push($metaKeys, $key);

			}

		}

		// Lets query the database to get only the values where we have registered the meta keys
		$postmetaSimple = $post->postmeta()
			->whereIn('meta_key', $metaKeys)
			->select(['meta_key', 'meta_value'])
			->get()
			->keyBy('meta_key')
			->toArray();

		// Lets attach the default post columns
		$defaultPostData = [];

		$defaultPostData['post_title'] = [
			'meta_key' => 'post_title',
			'meta_value' => $post->post_title,
		];

		$defaultPostData['post_name'] = [
			'meta_key' => 'post_name',
			'meta_value' => $post->post_name,
		];

		// Lets merge all the types of configs
		$postmeta = array_merge($postmetaSimple, $metaTaxonomies, $defaultPostData);

		// Return the post meta's
		return $postmeta;
	}
protected function retrieveConfigPostMetas($post, $postTypeModel)
	{
		$metaKeys = [];
		$metaTaxonomies = [];

		$allKeys = $this->getValidationsKeys($postTypeModel);
		foreach($allKeys as $key => $value){

			$customFieldObject = $this->getCustomFieldObject($postTypeModel, $key);

			if(isset($customFieldObject['type']) && $customFieldObject['type'] == 'taxonomy'){

				// We need to get the values from the taxonomy table
				if(array_key_exists('post_type', $customFieldObject)){

					$customfieldPostTypes = $this->getPostTypeIdentifiers($customFieldObject['post_type']);

					// Lets query the post to retrieve all the connected ids
					$taxonomyIds = $post->taxonomies()->whereIn('post_type', $customfieldPostTypes)
						->get();

					// Lets foreach all the posts because we only need the id
					$ids = [];
					foreach($taxonomyIds as $value){
						array_push($ids, $value->id);
					}

					$ids = json_encode($ids);

					$metaTaxonomies[$key] = [
						'meta_key' => $key,
						'meta_value' => $ids,
					];

				}

			// The other items are default
			} else {

				// Register it to the main array so we can query it later
				array_push($metaKeys, $key);

			}

		}

		// Lets query the database to get only the values where we have registered the meta keys
		$postmetaSimple = $post->postmeta()
			->whereIn('meta_key', $metaKeys)
			->select(['meta_key', 'meta_value'])
			->get()
			->keyBy('meta_key')
			->toArray();

		// Lets attach the default post columns
		$defaultPostData = [];

		$defaultPostData['post_title'] = [
			'meta_key' => 'post_title',
			'meta_value' => $post->post_title,
		];

		$defaultPostData['post_name'] = [
			'meta_key' => 'post_name',
			'meta_value' => $post->post_name,
		];

		// Lets merge all the types of configs
		$postmeta = array_merge($postmetaSimple, $metaTaxonomies, $defaultPostData);

		// Return the post meta's
		return $postmeta;
	}
protected function retrieveConfigPostMetas ( $ post , $ postTypeModel ) { $ metaKeys = [ ] ; $ metaTaxonomies = [ ] ; $ allKeys = $ this -> getValidationsKeys ( $ postTypeModel ) ; foreach ( $ allKeys as $ key => $ value ) { $ customFieldObject = $ this -> getCustomFieldObject ( $ postTypeModel , $ key ) ; if ( isset ( $ customFieldObject [ 'type' ] ) && $ customFieldObject [ 'type' ] == 'taxonomy' ) { // We need to get the values from the taxonomy table if ( array_key_exists ( 'post_type' , $ customFieldObject ) ) { $ customfieldPostTypes = $ this -> getPostTypeIdentifiers ( $ customFieldObject [ 'post_type' ] ) ; // Lets query the post to retrieve all the connected ids $ taxonomyIds = $ post -> taxonomies ( ) -> whereIn ( 'post_type' , $ customfieldPostTypes ) -> get ( ) ; // Lets foreach all the posts because we only need the id $ ids = [ ] ; foreach ( $ taxonomyIds as $ value ) { array_push ( $ ids , $ value -> id ) ; } $ ids = json_encode ( $ ids ) ; $ metaTaxonomies [ $ key ] = [ 'meta_key' => $ key , 'meta_value' => $ ids , ] ; } // The other items are default } else { // Register it to the main array so we can query it later array_push ( $ metaKeys , $ key ) ; } } // Lets query the database to get only the values where we have registered the meta keys $ postmetaSimple = $ post -> postmeta ( ) -> whereIn ( 'meta_key' , $ metaKeys ) -> select ( [ 'meta_key' , 'meta_value' ] ) -> get ( ) -> keyBy ( 'meta_key' ) -> toArray ( ) ; // Lets attach the default post columns $ defaultPostData = [ ] ; $ defaultPostData [ 'post_title' ] = [ 'meta_key' => 'post_title' , 'meta_value' => $ post -> post_title , ] ; $ defaultPostData [ 'post_name' ] = [ 'meta_key' => 'post_name' , 'meta_value' => $ post -> post_name , ] ; // Lets merge all the types of configs $ postmeta = array_merge ( $ postmetaSimple , $ metaTaxonomies , $ defaultPostData ) ; // Return the post meta's return $ postmeta ; }
Get all the post meta keys of the post
Get all the post meta keys of the post