ProdiSekolahController::update()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 25

Duplication

Lines 14
Ratio 41.18 %

Importance

Changes 0
Metric Value
cc 2
eloc 25
nc 2
nop 2
dl 14
loc 34
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Bantenprov\Sekolah\Http\Controllers;
4
5
/* Require */
6
use App\Http\Controllers\Controller;
7
use Illuminate\Http\Request;
8
use Bantenprov\Sekolah\Facades\SekolahFacade;
9
10
/* Models */
11
use Bantenprov\Sekolah\Models\Bantenprov\Sekolah\ProdiSekolah;
12
use Bantenprov\Sekolah\Models\Bantenprov\Sekolah\Sekolah;
13
use Bantenprov\ProgramKeahlian\Models\Bantenprov\ProgramKeahlian\ProgramKeahlian;
14
use App\User;
15
16
/* Etc */
17
use Validator;
18
use Auth;
19
20
/**
21
 * The ProdiSekolahController class.
22
 *
23
 * @package Bantenprov\Sekolah
24
 * @author  bantenprov <[email protected]>
25
 */
26
class ProdiSekolahController extends Controller
27
{
28
    protected $prodi_sekolah;
29
    protected $sekolah;
30
    protected $program_keahlian;
31
    protected $user;
32
33
    /**
34
     * Create a new controller instance.
35
     *
36
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
37
     */
38
    public function __construct()
39
    {
40
        $this->prodi_sekolah    = new ProdiSekolah;
41
        $this->sekolah          = new Sekolah;
42
        $this->program_keahlian = new ProgramKeahlian;
43
        $this->user             = new User;
44
    }
45
46
    /**
47
     * Display a listing of the resource.
48
     *
49
     * @return \Illuminate\Http\Response
50
     */
51
    public function index(Request $request)
52
    {
53
        if (request()->has('sort')) {
54
            list($sortCol, $sortDir) = explode('|', request()->sort);
55
56
            $query = $this->prodi_sekolah->orderBy($sortCol, $sortDir);
57
        } else {
58
            $query = $this->prodi_sekolah->orderBy('id', 'asc');
59
        }
60
61
        if ($request->exists('filter')) {
62
            $query->where(function($q) use($request) {
63
                $value = "%{$request->filter}%";
64
65
                $q->where('keterangan', 'like', $value)
66
                    ->orWhere('kuota_siswa', 'like', $value);
67
            });
68
        }
69
70
        $perPage = request()->has('per_page') ? (int) request()->per_page : null;
71
72
        $response = $query->with(['sekolah', 'program_keahlian', 'user'])->paginate($perPage);
73
74
        return response()->json($response)
75
            ->header('Access-Control-Allow-Origin', '*')
76
            ->header('Access-Control-Allow-Methods', 'GET');
77
    }
78
79
    /**
80
     * Display a listing of the resource.
81
     *
82
     * @return \Illuminate\Http\Response
83
     */
84
    public function get()
85
    {
86
        $prodi_sekolahs = $this->prodi_sekolah->with(['sekolah', 'program_keahlian', 'user'])->get();
87
88
        $response['prodi_sekolahs'] = $prodi_sekolahs;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
89
        $response['error']          = false;
90
        $response['message']        = 'Success';
91
        $response['status']         = true;
92
93
        return response()->json($response);
94
    }
95
96
    /**
97
     * Display a listing of the resource.
98
     *
99
     * @return \Illuminate\Http\Response
100
     */
101 View Code Duplication
    public function getBySekolah($id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
    {
103
        $prodi_sekolahs = $this->prodi_sekolah->where('sekolah_id', '=', $id)->with(['sekolah', 'program_keahlian', 'user'])->get();
104
105
        $response['prodi_sekolahs'] = $prodi_sekolahs;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
106
        $response['message']        = 'Success';
107
        $response['error']          = false;
108
        $response['status']         = true;
109
110
        return response()->json($response);
111
    }
112
113
    /**
114
     * Show the form for creating a new resource.
115
     *
116
     * @return \Illuminate\Http\Response
117
     */
118
    public function create()
119
    {
120
        $user_id            = isset(Auth::User()->id) ? Auth::User()->id : null;
121
        $prodi_sekolah      = $this->prodi_sekolah->getAttributes();
122
        $program_keahlians  = $this->program_keahlian->all();
123
        $users              = $this->user->getAttributes();
0 ignored issues
show
Unused Code introduced by
$users is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
124
        $users_special      = $this->user->all();
125
        $users_standar      = $this->user->findOrFail($user_id);
126
        $current_user       = Auth::User();
127
128
        foreach ($program_keahlians as $program_keahlian) {
129
            array_set($program_keahlian, 'label', $program_keahlian->label);
130
        }
131
132
        $role_check = Auth::User()->hasRole(['superadministrator','administrator']);
133
134 View Code Duplication
        if ($role_check) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
135
            $user_special = true;
136
137
            foreach ($users_special as $user) {
138
                array_set($user, 'label', $user->name);
139
            }
140
141
            $users = $users_special;
142
        } else {
143
            $user_special = false;
144
145
            array_set($users_standar, 'label', $users_standar->name);
146
147
            $users = $users_standar;
148
        }
149
150
        array_set($current_user, 'label', $current_user->name);
151
152
        $response['prodi_sekolah']      = $prodi_sekolah;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
153
        $response['program_keahlians']  = $program_keahlians;
154
        $response['users']              = $users;
155
        $response['user_special']       = $user_special;
156
        $response['current_user']       = $current_user;
157
        $response['error']              = false;
158
        $response['message']            = 'Success';
159
        $response['status']             = true;
160
161
        return response()->json($response);
162
    }
163
164
    /**
165
     * Store a newly created resource in storage.
166
     *
167
     * @param  \Illuminate\Http\Request  $request
168
     * @return \Illuminate\Http\Response
169
     */
170
    public function store(Request $request)
171
    {
172
        $prodi_sekolah = $this->prodi_sekolah;
173
174
        $validator = Validator::make($request->all(), [
175
            'sekolah_id'            => "required|exists:{$this->sekolah->getTable()},id",
176
            'program_keahlian_id'   => "required|exists:{$this->program_keahlian->getTable()},id|unique:{$this->prodi_sekolah->getTable()},program_keahlian_id,NULL,id,sekolah_id,{$request->input('sekolah_id')},deleted_at,NULL",
177
            'kuota_siswa'           => 'required|numeric|min:0|max:100000',
178
            'keterangan'            => 'max:255',
179
            'user_id'               => "required|exists:{$this->user->getTable()},id",
180
        ]);
181
182 View Code Duplication
        if ($validator->fails()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
183
            $error      = true;
184
            $message    = $validator->errors()->first();
185
        } else {
186
            $prodi_sekolah->sekolah_id          = $request->input('sekolah_id');
187
            $prodi_sekolah->program_keahlian_id = $request->input('program_keahlian_id');
188
            $prodi_sekolah->kuota_siswa         = $request->input('kuota_siswa');
189
            $prodi_sekolah->keterangan          = $request->input('keterangan');
190
            $prodi_sekolah->user_id             = $request->input('user_id');
191
            $prodi_sekolah->save();
192
193
            $error      = false;
194
            $message    = 'Success';
195
        }
196
197
        $response['prodi_sekolah']  = $prodi_sekolah;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
198
        $response['error']          = $error;
199
        $response['message']        = $message;
200
        $response['status']         = true;
201
202
        return response()->json($response);
203
    }
204
205
    /**
206
     * Display the specified resource.
207
     *
208
     * @param  \App\ProdiSekolah  $prodi_sekolah
0 ignored issues
show
Bug introduced by
There is no parameter named $prodi_sekolah. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
209
     * @return \Illuminate\Http\Response
210
     */
211 View Code Duplication
    public function show($id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
212
    {
213
        $prodi_sekolah = $this->prodi_sekolah->with(['sekolah', 'program_keahlian', 'user'])->findOrFail($id);
214
215
        $response['prodi_sekolah']  = $prodi_sekolah;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
216
        $response['error']          = false;
217
        $response['message']        = 'Success';
218
        $response['status']         = true;
219
220
        return response()->json($response);
221
    }
222
223
    /**
224
     * Show the form for editing the specified resource.
225
     *
226
     * @param  \App\Sekolah  $sekolah
0 ignored issues
show
Bug introduced by
There is no parameter named $sekolah. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
227
     * @return \Illuminate\Http\Response
228
     */
229
    public function edit($id)
230
    {
231
        $user_id            = isset(Auth::User()->id) ? Auth::User()->id : null;
232
        $prodi_sekolah      = $this->prodi_sekolah->with(['sekolah', 'program_keahlian', 'user'])->findOrFail($id);
233
        $program_keahlians  = $this->program_keahlian->all();
234
        $users              = $this->user->getAttributes();
0 ignored issues
show
Unused Code introduced by
$users is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
235
        $users_special      = $this->user->all();
236
        $users_standar      = $this->user->findOrFail($user_id);
237
        $current_user       = Auth::User();
238
239
        foreach ($program_keahlians as $program_keahlian) {
240
            array_set($program_keahlian, 'label', $program_keahlian->label);
241
        }
242
243
        $role_check = Auth::User()->hasRole(['superadministrator','administrator']);
244
245
        if ($prodi_sekolah->user !== null) {
246
            array_set($prodi_sekolah->user, 'label', $prodi_sekolah->user->name);
247
        }
248
249
        if ($role_check) {
250
            $user_special = true;
251
252
            foreach ($users_special as $user) {
253
                array_set($user, 'label', $user->name);
254
            }
255
256
            $users = $users_special;
257
        } else {
258
            $user_special = false;
259
260
            array_set($users_standar, 'label', $users_standar->name);
261
262
            $users = $users_standar;
263
        }
264
265
        array_set($current_user, 'label', $current_user->name);
266
267
        $response['prodi_sekolah']      = $prodi_sekolah;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
268
        $response['program_keahlians']  = $program_keahlians;
269
        $response['users']              = $users;
270
        $response['user_special']       = $user_special;
271
        $response['current_user']       = $current_user;
272
        $response['error']              = false;
273
        $response['message']            = 'Success';
274
        $response['status']             = true;
275
276
        return response()->json($response);
277
    }
278
279
    /**
280
     * Update the specified resource in storage.
281
     *
282
     * @param  \Illuminate\Http\Request  $request
283
     * @param  \App\Sekolah  $sekolah
0 ignored issues
show
Bug introduced by
There is no parameter named $sekolah. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
284
     * @return \Illuminate\Http\Response
285
     */
286
    public function update(Request $request, $id)
287
    {
288
        $prodi_sekolah = $this->prodi_sekolah->with(['sekolah', 'program_keahlian', 'user'])->findOrFail($id);
289
290
        $validator = Validator::make($request->all(), [
291
            'sekolah_id'            => "required|exists:{$this->sekolah->getTable()},id",
292
            'program_keahlian_id'   => "required|exists:{$this->program_keahlian->getTable()},id|unique:{$this->prodi_sekolah->getTable()},program_keahlian_id,{$id},id,sekolah_id,{$request->input('sekolah_id')},deleted_at,NULL",
293
            'kuota_siswa'           => 'required|numeric|min:0|max:100000',
294
            'keterangan'            => 'max:255',
295
            'user_id'               => "required|exists:{$this->user->getTable()},id",
296
        ]);
297
298 View Code Duplication
        if ($validator->fails()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
299
            $error      = true;
300
            $message    = $validator->errors()->first();
301
        } else {
302
            $prodi_sekolah->sekolah_id          = $request->input('sekolah_id');
303
            $prodi_sekolah->program_keahlian_id = $request->input('program_keahlian_id');
304
            $prodi_sekolah->kuota_siswa         = $request->input('kuota_siswa');
305
            $prodi_sekolah->keterangan          = $request->input('keterangan');
306
            $prodi_sekolah->user_id             = $request->input('user_id');
307
            $prodi_sekolah->save();
308
309
            $error      = false;
310
            $message    = 'Success';
311
        }
312
313
        $response['prodi_sekolah']  = $prodi_sekolah;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
314
        $response['error']          = $error;
315
        $response['message']        = $message;
316
        $response['status']         = true;
317
318
        return response()->json($response);
319
    }
320
321
    /**
322
     * Remove the specified resource from storage.
323
     *
324
     * @param  \App\Sekolah  $sekolah
0 ignored issues
show
Bug introduced by
There is no parameter named $sekolah. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
325
     * @return \Illuminate\Http\Response
326
     */
327 View Code Duplication
    public function destroy($id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
328
    {
329
        $prodi_sekolah = $this->prodi_sekolah->findOrFail($id);
330
331
        if ($prodi_sekolah->delete()) {
332
            $response['message']    = 'Success';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
333
            $response['success']    = true;
334
            $response['status']     = true;
335
        } else {
336
            $response['message']    = 'Failed';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$response was never initialized. Although not strictly required by PHP, it is generally a good practice to add $response = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
337
            $response['success']    = false;
338
            $response['status']     = false;
339
        }
340
341
        return json_encode($response);
342
    }
343
}
344