blue-twilight/app/ExternalService.php

46 lines
1.1 KiB
PHP

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