forked from hasi94/google_sheet_php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheetController.php
63 lines (54 loc) · 1.41 KB
/
sheetController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Jenssegers\Blade\Blade;
require_once ("services/sheetService.php");
/**
* Class sheetController
* Created by PhpStorm.
* User: Hasitha
* Date: 2/23/2022
* Time: 10:25 PM
*/
class sheetController
{
public function __construct()
{
$this->blade = new Blade('views', 'cache');
$this->sheet_service = new sheetService();
}
/**
* get the current data on sheet
*/
public function readSheet (){
$data = $this->sheet_service->readSheet();
echo $this->blade->render('show_data',['data'=>$data->values,'url'=>'/google_sheet/']);
}
/**
* overwrite the original sheet
*/
public function writeSheet () {
$data = array(
'Fname',
'Lname'
);
$data = $this->sheet_service->writeSheet($data);
return $this->readSheet();
}
/**
* append values to the original sheet
*/
public function appendSheet () {
$data = array(
'jhone','Doe','0712345698','[email protected]','1',Date('Y-m-d'),Date('H:m:s')
);
$data = $this->sheet_service->appendSheet($data);
return $this->readSheet();
}
public function url(){
return sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['SERVER_NAME'],
$_SERVER['REQUEST_URI']
);
}
}