PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / trunk
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration vtrunk
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Models / CommentImage.php

CommentImage.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration trunk, at app/Models/CommentImage.php

48 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Models;
4
5 use FluentBoards\App\Models\Comment;
6 use FluentBoards\App\Models\Task;
7 use FluentBoards\App\Services\Constant;
8
9 class CommentImage extends Attachment
10 {
11 public static function boot()
12 {
13 parent::boot();
14
15 static::creating(function ($model) {
16 $uid = wp_generate_uuid4();
17 $model->file_hash = md5($uid . wp_rand(0, 1000));
18 });
19 }
20
21 public function scopeWithComment($query)
22 {
23 return $query->where('object_type', Constant::COMMENT_IMAGE)->with('comment', function ($query) {
24 $query->select('id', 'board_id');
25 });
26 }
27
28 public function comment()
29 {
30 return $this->belongsTo(Comment::class, 'object_id', 'id');
31 }
32
33 public function getSecureUrlAttribute()
34 {
35 if ($this->attachment_type === 'url') {
36 return $this->full_url;
37 }
38 return add_query_arg([
39 'fbs' => 1,
40 'fbs_comment_image' => $this->file_hash,
41 'secure_sign' => md5($this->id . gmdate('YmdH'))
42 ], site_url('/index.php'));
43 }
44
45
46 }
47
48