54 lines
1.3 KiB
PHP
54 lines
1.3 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 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;
|
|
}
|
|
} |