-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Views.php
101 lines (78 loc) · 2.52 KB
/
Views.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace Thoughtco\KitchenDisplay\Models;
use Admin\Models\Categories_model;
use Admin\Models\Locations_model;
use ApplicationException;
use Exception;
use Igniter\Flame\Database\Traits\Validation;
use Illuminate\Support\Facades\Log;
use Model;
use Request;
class Views extends Model
{
use Validation;
/**
* @var string The database table name
*/
protected $table = 'thoughtco_kitchendisplay';
public $timestamps = TRUE;
public $casts = [
'locations' => 'array',
'categories' => 'array',
'display' => 'serialize',
];
public $rules = [
'name' => 'required',
'locations' => 'required',
'display.order_count' => 'required|int|min:0',
'display.refresh_interval' => 'required|int|min:10',
];
public function beforeSave()
{
if (!Request::input('View.name'))
$this->name = [];
if (!Request::input('View.locations'))
$this->locations = [];
if (!Request::input('View.categories'))
$this->categories = [];
}
public static function getCardLineOptions($line)
{
switch ($line)
{
case 1:
return [
0 => lang('lang:thoughtco.kitchendisplay::default.option_blank'),
1 => lang('lang:thoughtco.kitchendisplay::default.option_name_id'),
2 => lang('lang:thoughtco.kitchendisplay::default.option_id_name'),
];
break;
case 2:
return [
0 => lang('lang:thoughtco.kitchendisplay::default.option_blank'),
1 => lang('lang:thoughtco.kitchendisplay::default.option_phone_time_total'),
2 => lang('lang:thoughtco.kitchendisplay::default.option_time_phone_total'),
];
break;
case 3:
return [
0 => lang('lang:thoughtco.kitchendisplay::default.option_blank'),
1 => lang('lang:thoughtco.kitchendisplay::default.option_address'),
];
break;
}
return [];
}
public static function getCategoriesOptions()
{
return Categories_model::all()->pluck('name', 'category_id');
}
public static function getLocationsOptions()
{
$locations = [];
foreach (Locations_model::isEnabled()->get() as $location){
$locations[$location->location_id] = $location->location_name;
};
return collect($locations);
}
}