Skip to content

Commit

Permalink
Merge branch 'master' into feat/intro-excel-export
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.lock
  • Loading branch information
Niek Hoffmans committed Oct 7, 2019
2 parents 95a31ec + 0495b3b commit ba57566
Show file tree
Hide file tree
Showing 34 changed files with 2,719 additions and 1,710 deletions.
32 changes: 32 additions & 0 deletions app/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Api;

use App\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}

public function autoComplete(Request $request): JsonResponse
{
$users = User::query()
->where(function (Builder $query) use ($request) {
$term = $request->get('term', '');
$query->where('firstname', 'like' , "%$term%")
->orWhere('lastname', 'like' , "%$term%");
})
->selectRaw("CONCAT(firstname, ' ', lastname) as text")
->get();

return response()
->json($users);
}
}
Loading

0 comments on commit ba57566

Please sign in to comment.