Skip to content

Commit

Permalink
Make use of laravels named routes (closed #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Sep 16, 2016
1 parent d488c61 commit 1469c6c
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 63 deletions.
20 changes: 10 additions & 10 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php
Route::get('/', 'HomeController@index');
Route::get('register', function(){ return View::make('register')->with('pTitle', "Register"); });
Route::get('login', function(){ return View::make('login')->with('pTitle', "Login"); });
Route::get('faq', function(){ return View::make('faq')->with('pTitle', "FAQ"); });
Route::get('/', 'HomeController@index')->name('home');
Route::get('register', function(){ return View::make('register')->with('pTitle', "Register"); })->name('register');
Route::get('login', function(){ return View::make('login')->with('pTitle', "Login"); })->name('login');
Route::get('faq', function(){ return View::make('faq')->with('pTitle', "FAQ"); })->name('faq');

//----------------- User routes
Route::resource('users', 'UsersController', array('only' => array('show')));
Route::post('login', 'UsersController@login');
Route::post('make', 'UsersController@register');
Route::get('logout', 'UsersController@logout');
Route::get('logout', 'UsersController@logout')->name('logout');
Route::post('resetPassword/{id}','UsersController@resetPassword');

//----------------- Auth routes
Route::group(array('before' => 'auth'), function()
{
Route::get('hud', 'HomeController@index');
Route::get('search', 'HomeController@search');
Route::get('profile', 'UsersController@index');
Route::get('clients', 'ClientsController@index');
{
Route::get('hud', 'HomeController@index')->name('hud');
Route::get('search', 'HomeController@search')->name('search');
Route::get('profile', 'UsersController@index')->name('profile');
Route::get('clients', 'ClientsController@index')->name('clients');
Route::delete('clients/{id}', 'ClientsController@destroy');
Route::resource('projects', 'ProjectsController', array('only' => array('show')));

Expand Down
10 changes: 5 additions & 5 deletions public/assets/js/controllers/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var client = new Vue({

methods: {
getClients: function(){
$.get( "/api/clients/true", function( results ) {
$.get( window.baseurl + "/api/clients/true", function( results ) {
client.clients = results.data;
Vue.nextTick(function () {
megaMenuInit();
Expand All @@ -38,7 +38,7 @@ var client = new Vue({

$.ajax({
type: 'POST',
url: "/api/clients",
url: window.baseurl + "/api/clients",
data: new_client,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand Down Expand Up @@ -88,7 +88,7 @@ var client = new Vue({

$.ajax({
type: "POST",
url: "/api/clients/"+id,
url: window.baseurl + "/api/clients/"+id,
data: data,
success: function(e){
console.log(e);
Expand Down Expand Up @@ -118,7 +118,7 @@ var client = new Vue({
$("#confirm-btn").click(function(){
$.ajax({
type: "POST",
url: "/api/clients/"+currentClient.id,
url: window.baseurl + "/api/clients/"+currentClient.id,
data: {_method: "delete"},
success: function(){
client.clients.splice(clientIndex);
Expand Down Expand Up @@ -152,7 +152,7 @@ var client = new Vue({

$.ajax({
type: 'POST',
url: "/api/projects",
url: window.baseurl + "/api/projects",
data: client.newProject,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand Down
8 changes: 4 additions & 4 deletions public/assets/js/controllers/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ var hud = new Vue({
computed: {},
methods: {
getClients: function(){
$.get( "/api/clients/true", function( results ) {
$.get( window.baseurl + "/api/clients/true", function( results ) {
hud.clients = results.data.length;
}).fail(function(e){
console.log( "error "+ e );
});
},
getProjects: function(){
$.get( "/api/projects", function( results ) {
$.get( window.baseurl + "/api/projects", function( results ) {
hud.projects = results.data;
}).fail(function(e){
console.log( "error "+ e );
});
},
getSharedProjects: function(){
$.get( "/api/projects/shared", function( results ) {
$.get( window.baseurl + "/api/projects/shared", function( results ) {
hud.sharedProjects = results.data;
}).fail(function(e){
console.log( "error "+ e );
});
},
getTasks: function(){
$.get( "/api/tasks", function( results ) {
$.get( window.baseurl + "/api/tasks", function( results ) {
hud.tasks = results.data.length;
}).fail(function(e){
console.log( "error "+ e );
Expand Down
30 changes: 15 additions & 15 deletions public/assets/js/controllers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ var project = new Vue({
this.getOwner();
this.getMembers();
var url = window.location.href,
project_id = url.split('projects/')[1];
project_id = url.split('/').splice(-1);

$.get( "/api/projects/"+project_id, function( results ) {
$.get( window.baseurl + "/api/projects/"+project_id, function( results ) {
project.project = results.data;
Vue.nextTick(function () {
megaMenuInit();
Expand All @@ -139,7 +139,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/projects/"+ updatedProject.id,
url: window.baseurl + "/api/projects/"+ updatedProject.id,
data: updatedProject,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand All @@ -166,7 +166,7 @@ var project = new Vue({
$("#confirm-btn").click(function(){
$.ajax({
type: "POST",
url: "/api/tasks/"+taskId,
url: window.baseurl + "/api/tasks/"+taskId,
data: {_method: "delete"},
success: function(){
$(".task-"+taskId).hide();
Expand All @@ -189,7 +189,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/tasks/"+ client_id +"/"+ project_id,
url: window.baseurl + "/api/tasks/"+ client_id +"/"+ project_id,
data: project.newTask,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand Down Expand Up @@ -231,7 +231,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/tasks/"+ taskId,
url: window.baseurl + "/api/tasks/"+ taskId,
data: project.currentTask,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand All @@ -256,7 +256,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/credentials",
url: window.baseurl + "/api/credentials",
data: credential,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand Down Expand Up @@ -291,7 +291,7 @@ var project = new Vue({
$("#confirm-btn").click(function(){
$.ajax({
type: "POST",
url: "/api/credentials/"+credential.id,
url: window.baseurl + "/api/credentials/"+credential.id,
data: {_method: "delete"},
success: function(){
project.project.credentials.$remove(credential);
Expand All @@ -316,7 +316,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/credentials/"+ credentialId,
url: window.baseurl + "/api/credentials/"+ credentialId,
data: project.currentCredential,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand All @@ -334,9 +334,9 @@ var project = new Vue({
},
getOwner: function(){
var url = window.location.href,
project_id = url.split('projects/')[1];
project_id = url.split('/').splice(-1);

$.get( "/api/projects/"+project_id+"/owner", function( results ) {
$.get( window.baseurl + "/api/projects/"+project_id+"/owner", function( results ) {
project.owner = results.data;
Vue.nextTick(function () {
megaMenuInit();
Expand All @@ -347,9 +347,9 @@ var project = new Vue({
},
getMembers: function(){
var url = window.location.href,
project_id = url.split('projects/')[1];
project_id = url.split('/').splice(-1);

$.get( "/api/projects/"+project_id+"/members", function( results ) {
$.get( window.baseurl + "/api/projects/"+project_id+"/members", function( results ) {
project.members = results.data;
console.log(project.members);
Vue.nextTick(function () {
Expand All @@ -366,7 +366,7 @@ var project = new Vue({

$.ajax({
type: 'POST',
url: "/api/projects/"+ project_id +"/"+this.invited.email+"/invite",
url: window.baseurl + "/api/projects/"+ project_id +"/"+this.invited.email+"/invite",
data: project.currentCredential,
error: function(e) {
var response = jQuery.parseJSON(e.responseText);
Expand Down Expand Up @@ -394,7 +394,7 @@ var project = new Vue({
$("#confirm-btn").click(function(){
$.ajax({
type: "POST",
url: "/api/projects/"+project_id+"/"+member.id+"/remove",
url: window.baseurl + "/api/projects/"+project_id+"/"+member.id+"/remove",
data: {_method: "delete"},
success: function(){
project.members.$remove(member);
Expand Down
6 changes: 3 additions & 3 deletions public/assets/js/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var userObj = new Vue({

methods: {
getUser: function(){
$.get( "/api/user/", function( result ) {
$.get( window.baseurl + "/api/user", function( result ) {
userObj.user = result;
});
},
Expand All @@ -25,7 +25,7 @@ var userObj = new Vue({

$.ajax({
type: "POST",
url: "/api/user/"+data.id,
url: window.baseurl + "/api/user/"+data.id,
data: data,
success: function(result){
if(result.message != "Your changes have been saved"){
Expand All @@ -52,7 +52,7 @@ var userObj = new Vue({
$("#confirm-btn").click(function(){
$.ajax({
type: "DELETE",
url: "/api/user/",
url: window.baseurl + "/api/user/",
success: function(result){
document.location.href="/";
},
Expand Down
10 changes: 5 additions & 5 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<div class="container">
<div class="row">
<div class="col-xs-12">
<a href="/" class="pull-left"><img src="{{ \App\Helpers\Helpers::logoUrl() }}" alt="Ribbbon"></a>
<a href="/login" class="btn btn-primary btn-line pull-right login">Login</a>
<a href="/register" class="btn btn-primary btn-line pull-right register">Register</a>
<a href="{{ route('home') }}" class="pull-left"><img src="{{ \App\Helpers\Helpers::logoUrl() }}" alt="Ribbbon"></a>
<a href="{{ route('login') }}" class="btn btn-primary btn-line pull-right login">Login</a>
<a href="{{ route('register') }}" class="btn btn-primary btn-line pull-right register">Register</a>
<div class="clearfix"></div>
</div>
</div>
Expand All @@ -23,7 +23,7 @@
<div class="left-side">
<h1>Introducing Ribbbon 2.0</h1>
<h2>An open source project management system.</h2>
<a href="/register" class="btn btn-special">GET STARTED</a>
<a href="{{ route('register') }}" class="btn btn-special">GET STARTED</a>
</div>
<div class="right-side">
<img class="mascot" src="{{ asset('assets/img/mascot_left.png') }}" alt="">
Expand Down Expand Up @@ -119,7 +119,7 @@
<div class="col-xs-12">
<div class="img">
<h2>"Free, sexy, and open source. I think it's time for you to take the dive."</h2>
<a href="/register" class="btn btn-special">GET STARTED</a>
<a href="{{ route('register') }}" class="btn btn-special">GET STARTED</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/ins/clients/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<tbody>
<tr v-for="project in client.projects">
<td>@{{ $index + 1 }}</td>
<td><a href="/projects/@{{ project.id }}">@{{ project.name }}</a></td>
<td><a href="{{ route('projects.show', ['id' => '']) }}/@{{ project.id }}">@{{ project.name }}</a></td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/ins/hud.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<tbody>
<tr v-for="project in projects | filterBy my_project_text">
<td>@{{ $index + 1 }}</td>
<td><a href="/projects/@{{ project.id }}">@{{ project.name }}</a></td>
<td><a href="{{ route('projects.show', ['id' => '']) }}/@{{ project.id }}">@{{ project.name }}</a></td>
<td>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:@{{ project.completedWeight / project.totalWeight * 100 }}%;">
Expand All @@ -60,7 +60,7 @@
<template v-if="projects.length == 0">
<p class="alert alert-warning">
Your projects will be listed here once you create some.
Create a new project within the <a href="/clients">clients</a> page.
Create a new project within the <a href="{{ route('clients') }}">clients</a> page.
</p>
</template>
</div>
Expand All @@ -83,7 +83,7 @@
<tbody>
<tr v-for="project in sharedProjects | filterBy my_sproject_text">
<td>@{{ $index + 1 }}</td>
<td><a href="/projects/@{{ project.id }}">@{{ project.name }}</a></td>
<td><a href="{{ route('projects.show', ['id' => '']) }}/@{{ project.id }}">@{{ project.name }}</a></td>
<td>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:@{{ project.completedWeight / project.totalWeight * 100 }}%;">
Expand Down
12 changes: 6 additions & 6 deletions resources/views/ins/search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<div class="panel-body">
@if (count($clients) > 0)
@foreach ($clients as $client)
<a href="/clients/{{ $client->id }}">
{{ $client->name }}
<a href="{{ route('clients.show', ['id' => '']) }}/{{ $client->id }}">
{{ $client->name }}
</a>
@endforeach
@else
Expand All @@ -39,8 +39,8 @@
<div class="panel-body">
@if (count($projects) > 0)
@foreach ($projects as $project)
<a href="/projects/{{ $project->id }}">
{{ $project->name }}
<a href="{{ route('projects.show', ['id' => '']) }}/{{ $project->id }}">
{{ $project->name }}
<span class="weight pull-right">w.{{ $project->totalWeight()}}</span>
</a>
@endforeach
Expand All @@ -58,8 +58,8 @@
<div class="panel-body">
@if (count($tasks) > 0)
@foreach ($tasks as $task)
<a href="/projects/{{ $task->project_id }}">
{{ $task->name }}
<a href="{{ route('projects.show', ['id' => '']) }}/{{ $task->project_id }}">
{{ $task->name }}
<span class="weight pull-right">w.{{ $task->weight}}</span>
</a>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/ins/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="col-xs-12">
<section>
<div class="col-xs-12 col-md-4 left-side">
<a href="/profile"><img class="circle" src="{{ App\User::get_gravatar(Auth::user()->email) }}"></a>
<a href="{{ route('profile') }}"><img class="circle" src="{{ App\User::get_gravatar(Auth::user()->email) }}"></a>
<div class="info">
<p class="name">@{{ user.full_name }}</p>
<p class="color-primary">@{{ user.email }}</p>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@section('content')

<div class="special-form">
<a href="/"><img src="{{ \App\Helpers\Helpers::logoUrl() }}" alt=""></a>
<a href="{{ route('home') }}"><img src="{{ \App\Helpers\Helpers::logoUrl() }}" alt=""></a>
<h3 class="text-center">LOGIN</h3>
@if ($errors->first())
<span class="status-msg error-msg">{{ $errors->first() }}</span>
Expand All @@ -22,7 +22,7 @@
{!! Form::submit( 'Login', array('class' => 'btn btn-primary btn-wide')) !!}
</div>
{!! Form::close() !!}
<p>Don't have an account? <a href="/register">register</a></p>
<p>Don't have an account? <a href="{{ route('register') }}">register</a></p>
</div>

@stop
3 changes: 3 additions & 0 deletions resources/views/partials/head.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
</head>
<body>
@include('analyticstracking')
<script>
window.baseurl = '{{ route('home') }}'
</script>

<div id="sheet" class="animated"></div>
<div id="pop-up-prompt" class="animated">
Expand Down
Loading

0 comments on commit 1469c6c

Please sign in to comment.