laravel-websockets/src/Statistics/Rules/AppId.php

22 lines
582 B
PHP
Raw Normal View History

2018-12-03 12:33:00 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\Statistics\Rules;
2020-08-13 11:51:18 +00:00
use BeyondCode\LaravelWebSockets\Apps\AppManager;
2020-03-04 09:58:39 +00:00
use Illuminate\Contracts\Validation\Rule;
2018-12-03 12:33:00 +00:00
class AppId implements Rule
{
public function passes($attribute, $value)
{
2020-08-13 11:51:18 +00:00
$manager = app(AppManager::class);
2018-12-03 12:33:00 +00:00
2020-08-13 11:51:18 +00:00
return $manager->findById($value) ? true : false;
2018-12-03 12:33:00 +00:00
}
public function message()
{
2020-08-13 11:51:18 +00:00
return 'There is no app registered with the given id. Make sure the websockets config file contains an app for this id or that your custom AppManager returns an app for this id.';
2018-12-04 21:22:33 +00:00
}
}