File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App ;
4+
5+ use Illuminate \Database \Eloquent \Model ;
6+
7+ class Config extends Model
8+ {
9+ //
10+ }
Original file line number Diff line number Diff line change 33namespace App \Http \Controllers ;
44
55use Illuminate \Http \Request ;
6+ use App \Config ;
67
78class ConfigController extends Controller
89{
@@ -13,7 +14,20 @@ public function __construct()
1314
1415 public function index ()
1516 {
17+ $ configs = Config::all ();
1618 $ consumer_deploy_key = env ('CONSUMER_DEPLOY_KEY ' );
17- return view ('config/index ' ,compact ('consumer_deploy_key ' ));
19+ return view ('config/index ' ,compact ('consumer_deploy_key ' ,'configs ' ));
20+ }
21+
22+ public function config (Request $ request )
23+ {
24+ $ config = Config::where ('key ' ,'dhcp_global ' )->first ();
25+ if (is_null ($ config )) $ config = new Config ;
26+ $ config ->key = 'dhcp_global ' ;
27+ $ config ->value = $ request ->dhcp_global ;
28+ $ config ->save ();
29+
30+ $ request ->session ()->flash ('alert-success ' , 'Configuração atualizada com sucesso! ' );
31+ return redirect ("/config " );
1832 }
1933}
Original file line number Diff line number Diff line change 55use Illuminate \Http \Request ;
66use App \Rede ;
77use App \Equipamentos ;
8+ use App \Config ;
89
910use App \Utils \NetworkOps ;
1011use App \Utils \Utils ;
@@ -30,13 +31,16 @@ public function dhcpd(Request $request)
3031 $ ops = new NetworkOps ;
3132 $ date = Utils::ItensUpdatedAt ();
3233
34+ $ dhcp_global = Config::where ('key ' ,'dhcp_global ' )->first ();
35+ if (is_null ($ dhcp_global )){
36+ $ dhcp_global = new Config ;
37+ $ dhcp_global ->value = '' ;
38+ }
39+
3340 $ dhcp = <<<HEREDOC
3441# {$ date }
3542# build success
36- ddns-update-style none;
37- default-lease-time 86400;
38- max-lease-time 86400;
39- authoritative;
43+ {$ dhcp_global ->value }
4044shared-network "default" {
4145
4246HEREDOC ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Support \Facades \Schema ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Database \Migrations \Migration ;
6+
7+ class CreateConfigsTable extends Migration
8+ {
9+ /**
10+ * Run the migrations.
11+ *
12+ * @return void
13+ */
14+ public function up ()
15+ {
16+ Schema::create ('configs ' , function (Blueprint $ table ) {
17+ $ table ->increments ('id ' );
18+ $ table ->timestamps ();
19+ $ table ->text ('key ' );
20+ $ table ->longText ('value ' )->nullable ();
21+ });
22+ }
23+
24+ /**
25+ * Reverse the migrations.
26+ *
27+ * @return void
28+ */
29+ public function down ()
30+ {
31+ Schema::dropIfExists ('configs ' );
32+ }
33+ }
Original file line number Diff line number Diff line change 3535 </form >
3636</div >
3737
38+ <div >
39+
40+ <br >
41+ <form action =" /config" method =" post" >
42+ {{ csrf_field ()} }
43+ <div class =" panel panel-default" >
44+ <div class =" panel-heading" >Configurações para DHCP</div >
45+ <div class =" panel-body" >
46+ <div class =" form-group" >
47+ <label for =" dhcp_global" >Parâmetros globais</label >
48+
49+ @if (! is_null ($configs -> where (' key' ,' dhcp_global' )-> first ()) )
50+ <textarea rows =" 4" cols =" 50" class =" form-control" name =" dhcp_global" >{{ $configs -> where (' key' ,' dhcp_global' )-> first ()-> value } } </textarea >
51+ @else
52+ <textarea rows =" 4" cols =" 50" class =" form-control" name =" dhcp_global" >ddns-update-style none;
53+ default-lease-time 86400;
54+ max-lease-time 86400;
55+ authoritative;</textarea >
56+ @endif
57+ </div >
58+
59+ <div class =" form-group" >
60+ <input type =" submit" class =" btn btn-primary" value =" Enviar Dados" >
61+ </div >
62+ </div >
63+ </div >
64+ </div >
65+ </form >
66+
3867@stop
Original file line number Diff line number Diff line change 1515
1616# config
1717Route::get ('/config ' , 'ConfigController@index ' );
18+ Route::post ('/config ' , 'ConfigController@config ' );
1819Route::post ('/freeradius/sincronize ' , 'FreeradiusController@sincronize ' );
1920
2021# APIs
You can’t perform that action at this time.
0 commit comments