Created
January 13, 2024 20:01
-
-
Save chrismcintosh/cd31bb6462ecf3a8ecb90aaf67f5da53 to your computer and use it in GitHub Desktop.
Laravel Corcel default post query to trim down irrelevant data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Factories\HasFactory; | |
use Corcel\Model\Post as Corcel; | |
class Post extends Corcel | |
{ | |
use HasFactory; | |
protected $connection = 'wordpress'; | |
/** | |
* Structure WordPress post type to Laravel model | |
*/ | |
public function newQuery() | |
{ | |
return parent::newQuery() | |
->where('post_type', 'post') | |
->where('post_status', 'publish'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment