|
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Http\Requests\FilterRequest;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
class FilterController extends Controller
|
|
|
{
|
|
|
@@ -24,12 +25,16 @@ class FilterController extends Controller
|
|
|
|
|
|
$dbTable = self::DB_TABLES[$table];
|
|
|
|
|
|
- $q = DB::table($dbTable)->select($column)->distinct();
|
|
|
- if($table !== 'reclamations') {
|
|
|
- $q->where('year' , year());
|
|
|
+ if (Schema::hasColumn($dbTable, $column)) {
|
|
|
+ $q = DB::table($dbTable)->select($column)->distinct();
|
|
|
+ if($table !== 'reclamations') {
|
|
|
+ $q->where('year' , year());
|
|
|
+ }
|
|
|
+ $q->whereNull('deleted_at');
|
|
|
+ $result = $q->orderBy($column)->get()->pluck($column)->toArray();
|
|
|
+ } else {
|
|
|
+ $result = [];
|
|
|
}
|
|
|
- $q->whereNull('deleted_at');
|
|
|
- $result = $q->orderBy($column)->get()->pluck($column)->toArray();
|
|
|
|
|
|
return response()->json($result, 200, [], JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
|
|
|
}
|