Completed
Push — master ( f02542...f8d0c0 )
by Ricardo
02:27
created

TokenController::getPermissionOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Integrations\Http\Controllers\WebServices;
4
5
use Illuminate\Http\Request;
6
use Yajra\Datatables\Datatables;
7
use Facilitador\Exceptions\Exception;
8
use Facilitador\Http\Controllers\Admin\Base;
9
use Integrations\Models\Token;
10
11
class TokenController extends Base
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $title = 'Tokens';
17
    protected $model = Token::class;
18
19
    /**
20
     * @var string
21
     */
22
    protected $description = 'Listagem de Tokens.';
23
24
    /**
25
     * @var array
26
     */
27
    protected $columns = [
28
        'Rule' => 'getAdminTitleAttribute',
29
    ];
30
31
    /**
32
     * @var array
33
     */
34
    protected $search = [
35
        'from',
36
        'to',
37
        'code' => [
38
            'type' => 'select',
39
            'options' => 'Facilitador\Models\RedirectRule::getCodes()',
40
        ],
41
        'label',
42
    ];
43
44
    /**
45
     * Get the permission options.
46
     *
47
     * @return array An associative array.
48
     */
49
    public function getPermissionOptions()
50
    {
51
        return array_except(parent::getPermissionOptions(), ['publish']);
52
    }
53
54
    /**
55
     * Populate protected properties on init
56
     */
57
    public function __construct()
58
    {
59
        $this->title = __('facilitador::redirect_rules.controller.title');
60
        $this->description = __('facilitador::redirect_rules.controller.description');
61
        $this->columns = [
62
            __('facilitador::redirect_rules.controller.column.rule') => 'getAdminTitleAttribute',
63
        ];
64
        $this->search = [
65
            'from' => [
66
                'label' => __('facilitador::redirect_rules.controller.search.from'),
67
                'type' => 'text',
68
            ],
69
            'to' => [
70
                'label' => __('facilitador::redirect_rules.controller.search.to'),
71
                'type' => 'text',
72
            ],
73
            'code' => [
74
                'label' => __('facilitador::redirect_rules.controller.search.code'),
75
                'type' => 'select',
76
                'options' => 'Facilitador\Models\RedirectRule::getCodes()',
77
            ],
78
            'label' => [
79
                'label' => __('facilitador::redirect_rules.controller.search.label'),
80
                'type' => 'text',
81
            ],
82
        ];
83
84
        parent::__construct();
85
    }
86
87
    // /**
88
    //  * @var string
89
    //  */
90
    // public $description = "Listagem de Pedidos.";
91
92
    // /**
93
    //  * Display all the workers
94
    //  *
95
    //  * @return Illuminate\View\View
96
    //  */
97
    // public function index()
98
    // {
99
    //     return $this->populateView(
100
    //         'admin.orders.index', [
101
    //         'orders' => Order::orderBy('id', 'DESC')->simplePaginate(50),
102
    //         ]
103
    //     );
104
    // }
105
106
    // /**
107
    //  * Ajax service that tails the log file for the selected worker
108
    //  *
109
    //  * @param $worker
110
    //  */
111
    // public function tail($worker)
112
    // {
113
    //     // Form the path to the file
114
    //     $file = Worker::logPath(urldecode($worker));
115
    //     if (!file_exists($file)) {
116
    //         throw new Exception('Log not found: '.$file);
117
    //     }
118
    //     $size = 1024 * 100; // in bytes to get
119
120
    //     // Read from the end of the file
121
    //     clearstatcache();
122
    //     $fp = fopen($file, 'r');
123
    //     fseek($fp, -$size, SEEK_END);
124
    //     $contents = explode("\n", fread($fp, $size));
125
    //     fclose($fp);
126
127
    //     // Reverse the contents and return
128
    //     $contents = array_reverse($contents);
129
    //     if (empty($contents[0])) {
130
    //         array_shift($contents);
131
    //     }
132
    //     die(implode("\n", $contents));
133
    // }
134
135
    // /**
136
    //  * Display a listing of the resource.
137
    //  *
138
    //  * @return \Illuminate\Http\Response
139
    //  */
140
    // public function index(Request $request)
141
    // {
142
    //     // if ($request->ajax()) {
143
    //     //     $query = Order::with('user', 'operadora', 'collaborator', 'customer', 'money')->select('orders.*');
144
145
    //     //     return Datatables::of($query)->addColumn('action', function ($order) {
146
    //     //         return '<a href="'.route('admin.orders.show',$order->id).'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-eye"></i> Show</a>';
147
    //     //     })->setRowId('id')->editColumn('created_at', function ($order) {
148
    //     //         return $order->created_at->format('h:m:s d/m/Y');
149
    //     //     })
150
    //     //     ->setRowClass(function ($order) {
151
    //     //         return $order->status == Order::$STATUS_APPROVED ? 'alert-success' : 'alert-warning';
152
    //     //     })
153
    //     //     ->setRowData([
154
    //     //         'id' => 'test',
155
    //     //     ])
156
    //     //     ->setRowAttr([
157
    //     //         'color' => 'red',
158
    //     //     ])->make(true);
159
160
    //     //     return $this->dataTable->eloquent($query)->make(true);
161
    //     // }
162
    //     // return view('admin.orders.index');
163
164
    //     // USando Service //public function index(UsersDataTable $dataTable)
165
    //     // return $dataTable->render('orders.index');
166
167
    //     if ($request->has('query') && !empty($request->input('query'))) {
168
    //         dd('oi');
169
    //         $orders = Order::search($request->input('query'))->orderBy('id', 'DESC')->simplePaginate(50);
170
    //     } else {
171
    //         $orders = Order::orderBy('id', 'DESC')->simplePaginate(50);
172
    //     }
173
    //     return view('admin.orders.index', compact('orders'));
174
    // }
175
176
    // /**
177
    //  * Show the form for creating a new resource.
178
    //  *
179
    //  * @return \Illuminate\Http\Response
180
    //  */
181
    // public function create()
182
    // {
183
    //     return view('admin.orders.create');
184
    // }
185
186
    // /**
187
    //  * Store a newly created resource in storage.
188
    //  *
189
    //  * @param  \Illuminate\Http\Request  $request
190
    //  * @return \Illuminate\Http\Response
191
    //  */
192
    // public function store(Request $request)
193
    // {
194
    //   $request->validate([
195
    //     'total'=>'required',
196
    //     'money'=> 'required|integer',
197
    //     'operadora' => 'required|integer'
198
    //   ]);
199
    //   $order = new Order([
200
    //     'total' => $request->get('total'),
201
    //     'money'=> $request->get('money'),
202
    //     'operadora'=> $request->get('operadora')
203
    //   ]);
204
    //   $order->save();
205
    //   return redirect('/orders')->with('success', 'Stock has been added');
206
    // }
207
208
    // /**
209
    //  * Display the specified resource.
210
    //  *
211
    //  * @param  int  $id
212
    //  * @return \Illuminate\Http\Response
213
    //  */
214
    // public function show($id)
215
    // {
216
    //     $order = Order::findOrFail($id);
217
    //     return view('admin.orders.show', compact('order'));
218
    // }
219
    
220
221
    // /**
222
    //  * Show the form for editing the specified resource.
223
    //  *
224
    //  * @param  int  $id
225
    //  * @return \Illuminate\Http\Response
226
    //  */
227
    // public function edit($id)
228
    // {
229
    //     $order = Order::find($id);
230
231
    //     return view('admin.orders.edit', compact('order'));
232
    // }
233
234
    // /**
235
    //  * Update the specified resource in storage.
236
    //  *
237
    //  * @param  \Illuminate\Http\Request  $request
238
    //  * @param  int  $id
239
    //  * @return \Illuminate\Http\Response
240
    //  */
241
    // public function update(Request $request, $id)
242
    // {
243
    //     $request->validate([
244
    //         'total'=>'required',
245
    //         'money'=> 'required|integer',
246
    //         'operadora' => 'required|integer'
247
    //     ]);
248
249
    //     $order = Order::findOrFail($id);
250
    //     $order->total = $request->get('total');
251
    //     $order->money = $request->get('money');
252
    //     $order->operadora = $request->get('operadora');
253
    //     $order->save();
254
255
    //     return redirect('/orders')->with('success', 'Stock has been updated');
256
    // }
257
258
    // /**
259
    //  * Remove the specified resource from storage.
260
    //  *
261
    //  * @param  int  $id
262
    //  * @return \Illuminate\Http\Response
263
    //  */
264
    // public function destroy($id)
265
    // {
266
    //     $order = Order::findOrFail($id);
267
    //     $order->delete();
268
269
    //     return redirect('/orders')->with('success', 'Stock has been deleted Successfully');
270
    // }
271
}