-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Limiting users who can be messaged/found. #10
Comments
Hello @Braunson, thanks for your message, we should work on this feature for sure. We can add some options to the
Thoughts? Thanks! |
Hey @Braunson, for a quick solution to have Mercurius working with Teams in a Laravel Spark app, you can try this steps. Was not tested but will give you an idea.
Route::post('/receivers', 'App\Controllers\ReceiversController@search');
php artisan make:controller ReceiversController
Open namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ReceiversController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Search for receivers.
*
* @param Request $request
* @param UserRepository $userRepository
*
* @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
*/
public function search(Request $request, UserRepository $userRepository): Response
{
if (($query = $request->input('q')) === null) {
return response([
'hits' => [],
'total' => 0,
]);
}
// Apply filter to the Users in Teams/Users
// you will find this code on the UserRepository
// ------------------------------------------------
$limit = 6;
$userFqcn = config('mercurius.models.user');
$paginator = $userFqcn::where('name', 'LIKE', '%'.$query.'%')
->paginate($limit, [
'id',
'name',
'avatar',
'is_online',
]);
// ------------------------------------------------
$result = [
'total' => $paginator->total(),
'hits' => $paginator->items(),
];
return response($result);
}
} In a future release of Mercurius we will be able to load custom Controllers, using the Let us know the result. TY |
Hey - random thought that might be easier.... As Laravel you can apply scope classes via service providers. Just make a scope class that adds a new condition to only show users who should be visible? That way it’s as flexible as humanly possible as the scoping is 100% in the hands of the developer? |
Great idea @OwenMelbz, thanks for the tip. |
Description
In my case I'm using Laravel Spark, I only want a user to be able to message users within their team/teams. Regardless of Spark it would be nice to be able to "filter" the people they search/can have a conversation with.
The text was updated successfully, but these errors were encountered: