1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Phpsa\Datastore\Models\Traits\Attribute; |
4
|
|
|
use Phpsa\Datastore\Datastore as DatastoreFactory; |
5
|
|
|
use Phpsa\Datastore\Helpers; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait UserAttribute. |
9
|
|
|
*/ |
10
|
|
|
trait DatastoreAttribute |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @return string |
15
|
|
|
*/ |
16
|
|
|
public function getEditButtonAttribute() |
17
|
|
|
{ |
18
|
|
|
return '<a href="'.route('admin.ams.content.update', ['asset' => $this->content_path, 'id' => $this->id]).'" data-toggle="tooltip" data-placement="top" title="'.__('buttons.general.crud.edit').'" class="btn btn-primary"><i class="fas fa-edit"></i></a>'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return string |
23
|
|
|
*/ |
24
|
|
|
public function getDeleteButtonAttribute() |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
return '<a href="'.route('admin.ams.content.destroy', $this).'" |
28
|
|
|
data-method="delete" |
29
|
|
|
data-trans-button-cancel="'.__('buttons.general.cancel').'" |
30
|
|
|
data-trans-button-confirm="'.__('buttons.general.crud.delete').'" |
31
|
|
|
data-trans-title="'.__('strings.backend.general.are_you_sure').'" |
32
|
|
|
class="btn btn-danger"><i class="fas fa-trash" data-toggle="tooltip" data-placement="top" title="'.__('buttons.general.crud.delete').'"></i></a> '; |
33
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return string |
38
|
|
|
*/ |
39
|
|
|
public function getActionButtonsAttribute() |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
if($this->id) |
43
|
|
|
{ |
44
|
|
|
return '<div class="btn-group" role="group" aria-label="'.__('labels.backend.access.users.user_actions').'"> |
45
|
|
|
'.$this->edit_button.' |
46
|
|
|
'.$this->delete_button.' |
47
|
|
|
</div>'; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getContentPathAttribute(){ |
52
|
|
|
return Helpers::getPath($this->type); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/* public function getParentsAttribute(){ |
57
|
|
|
$rows = self::find(1); |
58
|
|
|
$data['parents'] = $this->db->query('select distinct(type), name, accept_limit from datastore where accept LIKE ?', array('%' . $newasset->type . '%'))->result_array(); |
59
|
|
|
|
60
|
|
|
}*/ |
61
|
|
|
|
62
|
|
|
public function getDatastoreAttribute(){ |
63
|
|
|
if($this->id){ |
64
|
|
|
return DatastoreFactory::getAsset($this->type, $this->id); |
65
|
|
|
} |
66
|
|
|
if($this->type){ |
67
|
|
|
return DatastoreFactory::dispence($this->type); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getRouteAttribute(){ |
72
|
|
|
return $this->type ? Helpers::callStatic($this->type, 'route', [$this]) : null; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function routeChild($parentSlug){ |
76
|
|
|
return $this->type ? Helpers::callStatic($this->type, 'route', [$this, $parentSlug]) : null; |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.