1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* rmarchiv.tk |
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace App\Http\Controllers; |
9
|
|
|
|
10
|
|
|
use App\Events\Obyx; |
11
|
|
|
use App\Models\Logo; |
12
|
|
|
use Illuminate\Http\Request; |
13
|
|
|
use Illuminate\Http\UploadedFile; |
14
|
|
|
|
15
|
|
|
class SubmitController extends Controller |
16
|
|
|
{ |
17
|
|
|
public function index() |
18
|
|
|
{ |
19
|
|
|
//Zeige Submit View |
20
|
|
|
return view('submit.index'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function logo_index() |
24
|
|
|
{ |
25
|
|
|
//Zeige View zum Einsenden eines Logos |
26
|
|
|
return view('submit.logo.index'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function logo_add(Request $request) |
30
|
|
|
{ |
31
|
|
|
$this->validate($request, [ |
32
|
|
|
'file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', |
33
|
|
|
'logoname' => 'required', |
34
|
|
|
]); |
35
|
|
|
|
36
|
|
|
$file = $request->file('file'); |
|
|
|
|
37
|
|
|
$extorig = $file->getExtension(); |
38
|
|
|
|
39
|
|
|
$imageName = \Storage::putFile('logos', new UploadedFile($file->path(), $file->getClientOriginalName())); |
40
|
|
|
//dd($file); |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
$l = new Logo(); |
|
|
|
|
45
|
|
|
$l->extension = \Storage::mimeType($imageName); |
46
|
|
|
$imageName = str_replace('logos', 'logo', $imageName); |
|
|
|
|
47
|
|
|
$l->filename = str_replace($extorig, '', $imageName); |
|
|
|
|
48
|
|
|
$l->title = $request->get('logoname'); |
|
|
|
|
49
|
|
|
$l->user_id = \Auth::id(); |
|
|
|
|
50
|
|
|
$l->save(); |
51
|
|
|
|
52
|
|
|
event(new Obyx('logo-add', \Auth::id())); |
53
|
|
|
|
54
|
|
|
return redirect()->route('submit.logo.success'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function attachment_submit(Request $request) |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
\Debugbar::disable(); |
60
|
|
|
|
61
|
|
|
$file = $request->file('editormd-image-file'); |
62
|
|
|
|
63
|
|
|
$imageName = \Storage::putFile('attachments', new UploadedFile($file->path(), $file->getClientOriginalName())); |
64
|
|
|
|
65
|
|
|
$response['url'] = url('/').'/storage/'.$imageName; |
|
|
|
|
66
|
|
|
$response['success'] = 1; |
|
|
|
|
67
|
|
|
$response['message'] = 'Bild wurde erfolgreich hochgeladen.'; |
|
|
|
|
68
|
|
|
$response['filename'] = url('/').'/storage/'.$imageName; |
69
|
|
|
|
70
|
|
|
return json_encode($response); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.