| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- declare (strict_types=1);
- namespace App\Model\Mongo;
- use Carbon\Carbon;
- use Hyperf\Mongodb\Mongodb;
- use Hyperf\Utils\ApplicationContext;
- use Hyperf\Utils\CodeGen\Project;
- use MongoDB\Client;
- /**
- * Class UserRelationModel
- * @return Client|UserRelationModel
- *
- * @package App\Model\Mongo
- */
- class SearchHotelLogModel extends Mongodb
- {
- protected $collectionName = 'search_hotel_log'; // mongoDB 表名
- protected $poolName = 'kaifang';
- public function db()
- {
- $container = ApplicationContext::getContainer();
- /**
- * @var $mongodb Client
- */
- $mongodb = $container->get(self::class);
- return $mongodb->selectDatabase(env('MONGODB_KAIFANG_DB'))
- ->selectCollection($this->collectionName);
- }
- public function create(string $userId, string $fid, array $project)
- {
- self::db()->insertOne([
- 'user_uid' => $userId,
- 'fid' => $fid,
- 'data' => json_encode($project),
- 'type' => 'chuji',
- 'created_at' => Carbon::now()->toDateTimeString(),
- ]);
- }
- }
|