-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWikiLogoController.php
More file actions
37 lines (29 loc) · 1.04 KB
/
WikiLogoController.php
File metadata and controls
37 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace App\Http\Controllers;
use App\Jobs\SetWikiLogo;
use App\WikiSetting;
use Illuminate\Http\Request;
class WikiLogoController extends Controller
{
/**
* It would be beneficial to have a bit of atomicness here?
* Right now WgLogo is always the same path when set, so if we start writing new files but die we still end up updating the site.
* Fine for now but...
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
*/
public function update(Request $request)
{
$request->validate([
'logo' => 'required|mimes:png',
]);
$wiki = $request->attributes->get('wiki');
// run the job to set the wiki logo
( new SetWikiLogo('id', $wiki->id, $request->file('logo')->getRealPath()) )->handle();
// get the logo URL from the settings
$wgLogoSetting = $wiki->settings()->firstWhere(['name' => WikiSetting::wgLogo])->value;
$res['success'] = true;
$res['url'] = $wgLogoSetting;
return response($res);
}
}