|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Common; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use App\Http\Controllers\Controller; |
|
7
|
|
|
use DateTime; |
|
8
|
|
|
use DateTimeZone; |
|
9
|
|
|
|
|
10
|
|
|
class BaseSettingsController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Get the logged activity |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getNewEntry($properties,$model) |
|
16
|
|
|
{ |
|
17
|
|
|
$properties = (array_key_exists('attributes', $properties->toArray())) ? ($model->properties['attributes']) : null; |
|
18
|
|
|
$display = ''; |
|
19
|
|
|
if ($properties != null) { |
|
20
|
|
|
if (array_key_exists('parent', $properties)) { |
|
21
|
|
|
unset($properties['parent']); |
|
22
|
|
|
} |
|
23
|
|
|
foreach ($properties as $key => $value) { |
|
24
|
|
|
$display[] = '<strong>'.'ucfirst'($key).'</strong>'.' : '.$value.'<br/>'; |
|
25
|
|
|
} |
|
26
|
|
|
$updated = (count($properties) > 0) ? implode('', $display) : '--'; |
|
27
|
|
|
return $updated; |
|
28
|
|
|
} |
|
29
|
|
|
else { |
|
30
|
|
|
return '--'; |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Get the older Entries |
|
36
|
|
|
*/ |
|
37
|
|
|
public function getOldEntry($data,$model) |
|
38
|
|
|
{ |
|
39
|
|
|
$oldData = ''; |
|
40
|
|
|
$oldData = (array_key_exists('old', $data->toArray())) ? ($model->properties['old']) : null; |
|
41
|
|
|
if ($oldData != null) { |
|
42
|
|
|
if ((count($oldData) > 0)) { |
|
43
|
|
|
foreach ($oldData as $key => $value) { |
|
44
|
|
|
$display[] = '<strong>'.'ucfirst'($key).'</strong>'.' : '.$value.'<br/>'; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
$old = (count($oldData) > 0) ? implode('', $display) : '--'; |
|
48
|
|
|
return $old; |
|
49
|
|
|
} else { |
|
50
|
|
|
return '--'; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Get Date |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getDate($dbdate) |
|
59
|
|
|
{ |
|
60
|
|
|
$created = new DateTime($dbdate); |
|
61
|
|
|
$tz = \Auth::user()->timezone()->first()->name; |
|
62
|
|
|
$created->setTimezone(new DateTimeZone($tz)); |
|
63
|
|
|
$date = $created->format('M j, Y, g:i a '); |
|
64
|
|
|
$newDate = $date; |
|
65
|
|
|
return $newDate; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|