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();
|
|
|
|
}
|
|
|
|
|
2020-04-29 22:19:21 +01:00
|
|
|
public function isDropbox()
|
2020-04-20 22:33:42 +01:00
|
|
|
{
|
2020-04-21 08:40:56 +01:00
|
|
|
// This logic must be mirrored in external_services.js
|
2020-04-29 22:19:21 +01:00
|
|
|
return $this->service_type == self::DROPBOX;
|
2020-04-19 10:54:07 +01:00
|
|
|
}
|
2020-04-21 08:40:56 +01:00
|
|
|
|
2020-04-29 22:19:21 +01:00
|
|
|
public function isFacebook()
|
2020-04-21 08:40:56 +01:00
|
|
|
{
|
|
|
|
// This logic must be mirrored in external_services.js
|
2020-04-29 22:19:21 +01:00
|
|
|
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;
|
2020-04-21 08:40:56 +01:00
|
|
|
}
|
2020-04-19 10:54:07 +01:00
|
|
|
}
|