PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Models/Media.php +26 -5 2.7.02.10.0 View file →
@@ -14,8 +14,25 @@
14 14 *
15 15 * @package FluentCommunity\App\Models
16 16 *
17 17 * @version 1.0.0
18 + *
19 + * @property int $id
20 + * @property string $object_source
21 + * @property int|null $user_id
22 + * @property string $media_key
23 + * @property int|null $feed_id
24 + * @property int $is_active
25 + * @property int|null $sub_object_id
26 + * @property string|null $media_type
27 + * @property string|null $driver
28 + * @property string|null $media_path
29 + * @property string|null $media_url
30 + * @property array $settings
31 + * @property string|null $created_at
32 + * @property string|null $updated_at
33 + * @property-read string $public_url
34 + * @property string|null $share_url
18 35 */
19 36 class Media extends Model
20 37 {
21 38 protected $table = 'fcom_media_archive';
@@ -21,11 +38,11 @@
21 38 protected $table = 'fcom_media_archive';
22 39
23 40 protected $primaryKey = 'id';
24 41
25 - protected $guarded = ['id'];
42 + protected $guarded = [ 'id' ];
26 43
27 - protected $appends = ['public_url'];
44 + protected $appends = [ 'public_url' ];
28 45
29 46 protected $fillable = [
30 47 'object_source',
31 48 'user_id',
@@ -36,9 +53,9 @@
36 53 'media_type',
37 54 'driver',
38 55 'media_path',
39 56 'media_url',
40 - 'settings'
57 + 'settings',
41 58 ];
42 59
43 60 public static function boot()
44 61 {
@@ -48,9 +65,13 @@
48 65 if (!isset($model->user_id)) {
49 66 $model->user_id = get_current_user_id();
50 67 }
51 68
52 - $model->media_key = $model->media_key ?: md5($model->media_url . '_' . time());
69 + if (!isset($model->object_source)) {
70 + $model->object_source = '';
71 + }
72 +
73 + $model->media_key = $model->media_key ? $model->media_key : md5($model->media_url . '_' . time());
53 74 });
54 75
55 76 static::deleting(function ($media) {
56 77 $media->deleteFile();
@@ -155,8 +176,8 @@
155 176 'id' => $this->id,
156 177 'url' => $this->getPrivateDownloadUrl(),
157 178 'media_key' => $this->media_key,
158 179 'title' => $this->getFileTitle(),
159 - 'type' => $this->media_type
180 + 'type' => $this->media_type,
160 181 ];
161 182 }
162 183 }