|
|
|
|
@ -4,6 +4,9 @@
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use EasyWeChat\Factory;
|
|
|
|
|
use Illuminate\Filesystem\Filesystem;
|
|
|
|
|
|
|
|
|
|
class CourseContent extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
protected $casts = ['publicize_ids' => 'json', 'file_ids' => 'json'];
|
|
|
|
|
@ -57,5 +60,32 @@ class CourseContent extends SoftDeletesModel
|
|
|
|
|
return $this->hasOne(CourseContentEvaluation::class, 'course_content_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取课程详情小程序码
|
|
|
|
|
*/
|
|
|
|
|
public function getCourseContentCheckQrcode($courseContentId)
|
|
|
|
|
{
|
|
|
|
|
$courseContent = self::find($courseContentId);
|
|
|
|
|
$path = config('filesystems.disks.public.root') . '/course_content_qrcode/' . $courseContent->id . '.png';
|
|
|
|
|
$url = config('filesystems.disks.public.url') . '/course_content_qrcode/' . $courseContent->id . '.png';
|
|
|
|
|
$fileSys = new Filesystem();
|
|
|
|
|
if ($fileSys->exists($path)) {
|
|
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
$config = [
|
|
|
|
|
'app_id' => \config('app.applet_appid'),
|
|
|
|
|
'secret' => \config('app.applet_secret')
|
|
|
|
|
];
|
|
|
|
|
$app = Factory::miniProgram($config);
|
|
|
|
|
$tmp = $app->app_code->get('/packages/surveyFill/index?course_content_id' . $courseContentId, [
|
|
|
|
|
'env_version' => "release" // 正式版
|
|
|
|
|
// 'env_version' => "trial" // 体验版
|
|
|
|
|
]);
|
|
|
|
|
$dir = dirname($path);
|
|
|
|
|
$fileSys->ensureDirectoryExists($dir, 0755, true);
|
|
|
|
|
$fileSys->put($path, $tmp);
|
|
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|