Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Jun 6, 2021
1 parent e7aae0c commit 1e02477
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public function scopeSearch($query, $searchData)
$queries = explode(' ', $searchData);
$query->distinct()->select(['posts.*', 'posts.id as id'])
->join('contents_of_posts', 'posts.id', '=', 'contents_of_posts.post_id')
->join('contents', 'contents.id', '=', 'contents_of_posts.content_id')
->where('contents.lang', '=', app()->getLocale());
->join('post_contents', 'post_contents.id', '=', 'contents_of_posts.content_id')
->where('post_contents.lang', '=', app()->getLocale());

foreach ($queries as $q){
$query->where('contents.title', 'like', '%'.$q.'%')
->orWhere('contents.content', 'like', '%'.$q.'%');
$query->where('post_contents.title', 'like', '%'.$q.'%')
->orWhere('post_contents.content', 'like', '%'.$q.'%');
}
}
return $query;
Expand Down Expand Up @@ -133,7 +133,7 @@ static private function selectByUrl($url)
{
return static::select(['posts.*', 'posts.id as id'])->distinct()
->join('contents_of_posts', 'posts.id', '=', 'contents_of_posts.post_id')
->join('contents', 'contents.id', '=', 'contents_of_posts.content_id')
->where('contents.url', '=', $url);
->join('post_contents', 'post_contents.id', '=', 'contents_of_posts.content_id')
->where('post_contents.url', '=', $url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('contents');
Schema::dropIfExists('post_contents');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function up()

$table->primary(['content_id', 'post_id']);
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
$table->foreign('content_id')->references('id')->on('contents')->onDelete('cascade');
$table->foreign('content_id')->references('id')->on('post_contents')->onDelete('cascade');
});
}

Expand Down

0 comments on commit 1e02477

Please sign in to comment.