blue-twilight/app/ExternalService.php

54 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?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', 'app_id', 'app_secret'];
/**
* 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 isDropbox()
{
// This logic must be mirrored in external_services.js
return $this->service_type == self::DROPBOX;
}
public function isFacebook()
{
// This logic must be mirrored in external_services.js
return $this->service_type == self::FACEBOOK;
}
public function isGoogle()
{
// This logic must be mirrored in external_services.js
return $this->service_type == self::GOOGLE;
}
public function isTwitter()
{
// This logic must be mirrored in external_services.js
return $this->service_type == self::TWITTER;
}
}