2016-10-18 15:11:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Storage as LaravelStorage;
|
|
|
|
|
|
|
|
class Storage {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save backup as json into /public/exports.
|
|
|
|
*
|
|
|
|
* @param $file
|
|
|
|
* @param $items
|
|
|
|
*/
|
|
|
|
public function saveExport($file, $items)
|
|
|
|
{
|
|
|
|
LaravelStorage::disk('export')->put($file, $items);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-23 22:26:04 +01:00
|
|
|
* Download the poster image file.
|
2016-10-18 15:11:25 +02:00
|
|
|
*
|
|
|
|
* @param $poster
|
|
|
|
*/
|
2017-01-23 22:26:04 +01:00
|
|
|
public function downloadPoster($poster)
|
2016-10-18 15:11:25 +02:00
|
|
|
{
|
|
|
|
if($poster) {
|
|
|
|
LaravelStorage::put($poster, file_get_contents('http://image.tmdb.org/t/p/w185' . $poster));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete the poster image file.
|
|
|
|
*
|
|
|
|
* @param $poster
|
|
|
|
*/
|
|
|
|
public function removePosterFile($poster)
|
|
|
|
{
|
|
|
|
LaravelStorage::delete($poster);
|
|
|
|
}
|
2016-11-23 21:16:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse language file.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function parseLanguage()
|
|
|
|
{
|
|
|
|
$alternative = config('app.TRANSLATION') ?: 'EN';
|
|
|
|
$filename = strtolower($alternative) . '.json';
|
|
|
|
|
|
|
|
// Get english fallback
|
|
|
|
if( ! LaravelStorage::disk('languages')->exists($filename)) {
|
|
|
|
$filename = 'en.json';
|
|
|
|
}
|
|
|
|
|
|
|
|
return LaravelStorage::disk('languages')->get($filename);
|
|
|
|
}
|
2016-10-18 15:11:25 +02:00
|
|
|
}
|