Commit 7268da43 authored by Jack Stupple's avatar Jack Stupple

paperwork needed localizing

parent 056f80f2
......@@ -11,6 +11,8 @@ class PaperworkController extends Controller {
return [];
}
return \App\Paperwork::where('character_id', $player->character_id)->get();
return \App\Paperwork::where('character_id', $player->character_id)
->where('language_id', $player->language_id)
->get();
}
}
......@@ -18,23 +18,32 @@ class AddCharacterPaperwork extends Migration
Schema::create('paperwork', function(Blueprint $blueprint) {
$blueprint->increments('id');
$blueprint->integer('character_id');
$blueprint->integer('language_id');
$blueprint->longText('uri');
$blueprint->timestamps();
});
$characters = ['emily', 'jamal', 'jake', 'ann'];
$languages = \App\Language::whereRaw('enabled <= NOW()')->get();
foreach ($characters as $_character) {
$json_path = APP_ROOT . '/resources/data/' . $_character . '/paperwork.json';
if (!file_exists($json_path)) continue;
$character = \App\Character::where('name', 'LIKE', $_character)->first();
$json = json_decode(file_get_contents($json_path));
foreach ($json as $_page) {
$page = $character->paperwork()->create();
$page->uri = 'data:image/png;base64,' . base64_encode(file_get_contents(APP_ROOT . '/resources/assets/characters/' . $_character . '/paperwork/' . $_page));
$page->save();
$paperwork = json_decode(file_get_contents($json_path), 1);
foreach ($languages as $language) {
if (!isset($paperwork[$language->slug])) {
continue;
}
foreach ($paperwork[$language->slug] as $_page) {
$page = $character->paperwork()->create();
$page->language_id = $language->id;
$page->uri = 'data:image/png;base64,' . base64_encode(file_get_contents(APP_ROOT . '/resources/assets/characters/' . $_character . '/paperwork/' . $_page));
$page->save();
}
}
}
}
......
[
"emily-paperwork-1.png",
"emily-paperwork-2.png",
"emily-paperwork-3.png"
]
{
"en": [
"emily-paperwork-1.png",
"emily-paperwork-2.png",
"emily-paperwork-3.png"
],
"fr": [
"emily-paperwork-1.png",
"emily-paperwork-2.png",
"emily-paperwork-3.png"
]
}
[
"jamal-paperwork-1.png",
"jamal-paperwork-2.png",
"jamal-paperwork-3.png"
]
{
"en": [
"jamal-paperwork-1.png",
"jamal-paperwork-2.png",
"jamal-paperwork-3.png"
],
"fr": []
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment