ajax testing
This commit is contained in:
44
app/Http/Controllers/AjaxController.php
Normal file
44
app/Http/Controllers/AjaxController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use DB;
|
||||
use App\Library\Fleets;
|
||||
|
||||
use App\Models\Fleet;
|
||||
|
||||
class AjaxController extends Controller {
|
||||
|
||||
public function index() {
|
||||
$msg = "This is a simple message.";
|
||||
return response()->json(array('msg'=> $msg), 200);
|
||||
}
|
||||
|
||||
public function displayFleet() {
|
||||
$fleets = Fleet::all();
|
||||
$data = array();
|
||||
$fc = array();
|
||||
$fleet = array();
|
||||
$description = array();
|
||||
$i = 0;
|
||||
|
||||
foreach($fleets as $fl) {
|
||||
$fc[$i] = $fl->character_id;
|
||||
$fleet[$i] = $fl->fleet;
|
||||
$description[$i] = $fl->description;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$data = [
|
||||
$fc,
|
||||
$fleet,
|
||||
$description,
|
||||
];
|
||||
|
||||
return response()->json(array('data' => $data), 200);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -16,6 +21,7 @@ class DashboardController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Guest');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,7 +34,23 @@ class DashboardController extends Controller
|
||||
return view('dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the profile of the user
|
||||
* The profile will include the ESI Scopes Registered, the character image, and character name
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function profile() {
|
||||
//
|
||||
$scopes = DB::table('EsiScopes')->where('character_id', Auth()->user()->character_id)->get();
|
||||
$permissions = DB::table('user_permissions')->where('charcter_id', Auth()->user()->character_id)->get();
|
||||
$roles = DB::table('user_roles')->where('character_id', Auth()->user()->character_id)->get();
|
||||
|
||||
$data = [
|
||||
'scopes' => $scopes,
|
||||
'permissions' => $permissions,
|
||||
'roles' => $roles,
|
||||
];
|
||||
|
||||
return view('/dashboard/profile')->with('data', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ class FleetsController extends Controller
|
||||
return view('fleets.registerfleet');
|
||||
}
|
||||
|
||||
public function displayFleetSetup() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function displayFleets() {
|
||||
$fleets = Fleet::all();
|
||||
$data = array();
|
||||
@@ -46,8 +51,6 @@ class FleetsController extends Controller
|
||||
$description,
|
||||
];
|
||||
|
||||
$size = sizeof($fc);
|
||||
|
||||
//Return the view with the array of the fleet
|
||||
return view('fleets.displayfleets')->with('data', $data);
|
||||
}
|
||||
|
||||
10
resources/views/ajax/message.blade.php
Normal file
10
resources/views/ajax/message.blade.php
Normal file
@@ -0,0 +1,10 @@
|
||||
@extends('layouts.ajaxb4')
|
||||
@section('content')
|
||||
|
||||
<div id = 'msg'>This message will be replaced using Ajax.
|
||||
Click the button to replace the message.</div>
|
||||
<?php
|
||||
echo Form::button('Replace Message',['onClick'=>'getMessage()']);
|
||||
?>
|
||||
|
||||
@endsection
|
||||
42
resources/views/layouts/ajaxb4.blade.php
Normal file
42
resources/views/layouts/ajaxb4.blade.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<!doctype html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<title>{{ config('app.name', 'W4RP Services') }}</title>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<!-- Bootstrap CSS
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
|
||||
-->
|
||||
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
|
||||
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||
<script>
|
||||
function getMessage(){
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url:'/getmsg',
|
||||
data:'_token = <?php echo csrf_token() ?>',
|
||||
success:function(data){
|
||||
$("#msg").html(data.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@include('layouts.navbar')
|
||||
<div class="container">
|
||||
@include('inc.messages')
|
||||
</div>
|
||||
@yield('content')
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -63,4 +63,10 @@ Route::get('/finances/taxes', 'FinancesController@displayTaxes')->name('structur
|
||||
|
||||
//Structures Controller display pages
|
||||
Route::get('/structures/register', 'RegisterStructureController@displayRegisterstructure');
|
||||
Route::post('/structures/store', 'RegisterStructureController@storeStructure');
|
||||
Route::post('/structures/store', 'RegisterStructureController@storeStructure');
|
||||
|
||||
//AJAX Controller display pages
|
||||
Route::get('ajax',function() {
|
||||
return view('/ajax/message');
|
||||
});
|
||||
Route::post('/getmsg','AjaxController@index');
|
||||
Reference in New Issue
Block a user