| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Module\Transaction\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use UCore\ModelCore;
- /**
- * 交易记录
- *
- * field start
- * field end
- */
- class Transaction extends ModelCore
- {
- // attrlist start
- protected $fillable = [
- ];
- // attrlist end
- use HasDateTimeFormatter;
- protected $table = 'transaction';
- /**
- * @param $data
- * @return int
- */
- public static function insert($data)
- {
- $model = new self();
- $model->transaction_no = $data['transaction_no'];
- $model->user_id = $data['user_id'];
- $model->from_user_id = $data['from_user_id'];
- $model->to_user_id = $data['to_user_id'];
- $model->coin_type = $data['coin_type'];
- $model->type = $data['type'];
- $model->amount = $data['amount'];
- $model->status = $data['status'];
- $model->save();
- return $model->id;
- }
- /**
- * @param $userId
- * @param $id
- * @return \Illuminate\Database\Eloquent\Collection
- */
- public static function getData($userId, $id)
- {
- $query = self::query();
- $query->where('user_id', $userId);
- $query->where('id', $id);
- return $query->first();
- }
- }
|