server/app/Model/AccountPost.php

38 lines
890 B
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Db;
/**
* @property int $account_id
* @property int $post_id
*/
class AccountPost extends \Hyperf\Database\Model\Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'account_post';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['account_id' => 'integer', 'post_id' => 'integer'];
public static function getPost(int $account_id)
{
return Db::table("account_post")
->leftJoin('post', 'post.post_id', '=', 'account_post.post_id')
->where('account_post.account_id', $account_id)
->select(["post.post_id", "post.post_name"])->get()->toArray();
}
}