From 39aa8530424310663c888f9e02224158961532e3 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 30 Oct 2018 18:41:29 +0100 Subject: PHP is crap --- api/Posts/Repositories/PostRepository.php | 60 ------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 api/Posts/Repositories/PostRepository.php (limited to 'api/Posts/Repositories/PostRepository.php') diff --git a/api/Posts/Repositories/PostRepository.php b/api/Posts/Repositories/PostRepository.php deleted file mode 100644 index c554e82..0000000 --- a/api/Posts/Repositories/PostRepository.php +++ /dev/null @@ -1,60 +0,0 @@ -with('post_type'); - $this->applyResourceOptions($query, $options); - $posts = $query->get(); - $joinedPosts = []; - - foreach ($posts as $post) { - $postType = 'Api\Posts\Models\\' . $post["post_type"]["type"] . 'Post'; - $postTypeClass = new $postType(); - $post["post"] = $postTypeClass::query()->where('id', $post->id)->first(); - array_push($joinedPosts, $post); - } - return $joinedPosts; - } - - public function getJoinedById($postId) - { - $query = Post::query()->with('post_type')->where('id', $postId); - $post = $query->first(); - - $postType = 'Api\Posts\Models\\' . $post["post_type"]["type"] . 'Post'; - $postTypeClass = new $postType(); - $post["post"] = $postTypeClass::query()->where('id', $post["id"])->first(); - return $post; - } - - public function create(array $data) - { - $post = $this->getModel(); - - $post->fill($data); - $post->save(); - - return $post; - } - - public function update(Post $post, array $data) - { - $post->fill($data); - - $post->save(); - - return $post; - } -} -- cgit v1.2.3