mirror of
https://github.com/devfake/flox.git
synced 2024-11-15 22:52:32 +01:00
619e407bcd
* start with subpage design * transitions * transitions * transitions, stuff * modal for trailer * english fallback for trailers * slugs in url * bit refactor * tests and fixtures * travis * update production files * move time limit to config and display error message to user * fix import * fix review
94 lines
2.0 KiB
PHP
94 lines
2.0 KiB
PHP
<?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);
|
|
}
|
|
|
|
/**
|
|
* Create the export filename.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function createExportFilename()
|
|
{
|
|
return 'flox--' . date('Y-m-d---H-i') . '.json';
|
|
}
|
|
|
|
/**
|
|
* Download the poster image files.
|
|
*
|
|
* @param $poster
|
|
*/
|
|
public function downloadPoster($poster)
|
|
{
|
|
if($poster) {
|
|
LaravelStorage::put($poster, file_get_contents(config('services.tmdb.poster') . $poster));
|
|
LaravelStorage::disk('subpage')->put($poster, file_get_contents(config('services.tmdb.poster_subpage') . $poster));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Download the backdrop image file.
|
|
*
|
|
* @param $backdrop
|
|
*/
|
|
public function downloadBackdrop($backdrop)
|
|
{
|
|
if($backdrop) {
|
|
LaravelStorage::disk('backdrop')->put($backdrop, file_get_contents(config('services.tmdb.backdrop') . $backdrop));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Delete the poster image files.
|
|
*
|
|
* @param $poster
|
|
*/
|
|
public function removePoster($poster)
|
|
{
|
|
LaravelStorage::delete($poster);
|
|
LaravelStorage::disk('subpage')->delete($poster);
|
|
}
|
|
|
|
/**
|
|
* Delete the backdrop image.
|
|
*
|
|
* @param $backdrop
|
|
*/
|
|
public function removeBackdrop($backdrop)
|
|
{
|
|
LaravelStorage::disk('backdrop')->delete($backdrop);
|
|
}
|
|
|
|
/**
|
|
* Parse language file.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function parseLanguage()
|
|
{
|
|
$alternative = config('app.TRANSLATION');
|
|
$filename = strtolower($alternative) . '.json';
|
|
|
|
// Get english fallback
|
|
if( ! LaravelStorage::disk('languages')->exists($filename)) {
|
|
$filename = 'en.json';
|
|
}
|
|
|
|
return LaravelStorage::disk('languages')->get($filename);
|
|
}
|
|
}
|