Completed
Push — development ( 75522b...9443e0 )
by Ashutosh
09:07
created

BaseSettingsController::getNewEntry()   A

Complexity

Conditions 6
Paths 18

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 16
rs 9.2222
c 0
b 0
f 0
cc 6
nc 18
nop 2
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