public function search($input) { $query = Comment::query(); $columns = Schema::getColumnListing('comments'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }
public function show($id) { return response()->json(Comment::query()->findOrFail($id)); }