2020-04-19 10:54:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class ExternalService extends Model
|
|
|
|
{
|
2020-04-20 22:33:42 +01:00
|
|
|
public const DROPBOX = 'dropbox';
|
|
|
|
public const FACEBOOK = 'facebook';
|
|
|
|
public const GOOGLE = 'google';
|
|
|
|
public const TWITTER = 'twitter';
|
2020-04-19 10:54:07 +01:00
|
|
|
|
|
|
|
/**
|
2020-04-20 22:33:42 +01:00
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['name', 'service_type'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets all possible service configurations for the given service type.
|
2020-04-19 10:54:07 +01:00
|
|
|
* @param $serviceType
|
2020-04-20 22:33:42 +01:00
|
|
|
* @return ExternalService[]
|
2020-04-19 10:54:07 +01:00
|
|
|
*/
|
|
|
|
public static function getForService($serviceType)
|
|
|
|
{
|
2020-04-20 22:33:42 +01:00
|
|
|
return ExternalService::where('service_type', $serviceType)->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasOAuthStandardOptions()
|
|
|
|
{
|
2020-04-21 08:40:56 +01:00
|
|
|
// This logic must be mirrored in external_services.js
|
2020-04-20 22:33:42 +01:00
|
|
|
return in_array($this->service_type, [
|
|
|
|
self::FACEBOOK,
|
|
|
|
self::GOOGLE,
|
|
|
|
self::TWITTER
|
|
|
|
]);
|
2020-04-19 10:54:07 +01:00
|
|
|
}
|
2020-04-21 08:40:56 +01:00
|
|
|
|
|
|
|
public function isDropbox()
|
|
|
|
{
|
|
|
|
// This logic must be mirrored in external_services.js
|
|
|
|
return $this->service_type == self::DROPBOX;
|
|
|
|
}
|
2020-04-19 10:54:07 +01:00
|
|
|
}
|