7
7
8
8
use Auth ;
9
9
use DB ;
10
+ use ZipArchive ;
10
11
11
12
use App \Models \User ;
12
13
use App \Models \Button ;
13
14
use App \Models \Link ;
14
15
16
+
15
17
//Function tests if string starts with certain string (used to test for illegal strings)
16
18
function stringStartsWith ($ haystack ,$ needle ,$ case =true ) {
17
19
if ($ case ){
@@ -56,8 +58,8 @@ public function littlelink(request $request)
56
58
return abort (404 );
57
59
}
58
60
59
- $ userinfo = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' )->where ('id ' , $ id )->first ();
60
- $ information = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' )->where ('id ' , $ id )->get ();
61
+ $ userinfo = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' , ' theme ' )->where ('id ' , $ id )->first ();
62
+ $ information = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' , ' theme ' )->where ('id ' , $ id )->get ();
61
63
62
64
$ links = DB ::table ('links ' )->join ('buttons ' , 'buttons.id ' , '= ' , 'links.button_id ' )->select ('links.link ' , 'links.id ' , 'links.button_id ' , 'links.title ' , 'links.custom_css ' , 'links.custom_icon ' , 'buttons.name ' )->where ('user_id ' , $ id )->orderBy ('up_link ' , 'asc ' )->orderBy ('order ' , 'asc ' )->get ();
63
65
@@ -74,8 +76,8 @@ public function littlelinkhome(request $request)
74
76
return abort (404 );
75
77
}
76
78
77
- $ userinfo = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' )->where ('id ' , $ id )->first ();
78
- $ information = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' )->where ('id ' , $ id )->get ();
79
+ $ userinfo = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' , ' theme ' )->where ('id ' , $ id )->first ();
80
+ $ information = User::select ('name ' , 'littlelink_name ' , 'littlelink_description ' , ' theme ' )->where ('id ' , $ id )->get ();
79
81
80
82
$ links = DB ::table ('links ' )->join ('buttons ' , 'buttons.id ' , '= ' , 'links.button_id ' )->select ('links.link ' , 'links.id ' , 'links.button_id ' , 'links.title ' , 'links.custom_css ' , 'links.custom_icon ' , 'buttons.name ' )->where ('user_id ' , $ id )->orderBy ('up_link ' , 'asc ' )->orderBy ('order ' , 'asc ' )->get ();
81
83
@@ -301,8 +303,47 @@ public function editPage(request $request)
301
303
return Redirect ('/studio/page ' );
302
304
}
303
305
306
+ //Show custom theme
307
+ public function showTheme (request $ request )
308
+ {
309
+ $ userId = Auth::user ()->id ;
310
+
311
+ $ data ['pages ' ] = User::where ('id ' , $ userId )->select ('littlelink_name ' , 'theme ' )->get ();
312
+
313
+ return view ('/studio/theme ' , $ data );
314
+ }
315
+
316
+ //Save custom theme
317
+ public function editTheme (request $ request )
318
+ {
319
+ $ request ->validate ([
320
+ 'zip ' => 'sometimes|mimes:zip ' ,
321
+ ]);
322
+
323
+ $ userId = Auth::user ()->id ;
324
+
325
+ $ zipfile = $ request ->file ('zip ' );
326
+
327
+ $ theme = $ request ->theme ;
328
+
329
+ User::where ('id ' , $ userId )->update (['theme ' => $ theme ]);
330
+
331
+ if (!empty ($ zipfile )){
332
+
333
+ $ zipfile ->move (base_path ('/themes ' ), "temp.zip " );
334
+
335
+ $ zip = new ZipArchive ;
336
+ $ zip ->open (base_path () . '/themes/temp.zip ' );
337
+ $ zip ->extractTo (base_path () . '/themes ' );
338
+ $ zip ->close ();
339
+ unlink (base_path () . '/themes/temp.zip ' );
340
+ }
341
+
342
+ return Redirect ('/studio/theme ' );
343
+ }
344
+
304
345
//Show user (name, email, password)
305
- public function showProfile ()
346
+ public function showProfile (request $ request )
306
347
{
307
348
$ userId = Auth::user ()->id ;
308
349
0 commit comments