forked from nathalie/pedi2
		
	Navigation bar. Middleware que te lleva a Crear o elegir tu subpedido
This commit is contained in:
		
							parent
							
								
									026af6a63d
								
							
						
					
					
						commit
						6cab6f1fdd
					
				
					 10 changed files with 105 additions and 58 deletions
				
			
		|  | @ -13,7 +13,7 @@ class ProductoController extends Controller | ||||||
|      */ |      */ | ||||||
|     public function __construct() |     public function __construct() | ||||||
|     { |     { | ||||||
|         $this->middleware('auth'); |         $this->middleware(['auth','subpedido']); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  |  | ||||||
|  | @ -63,6 +63,7 @@ class Kernel extends HttpKernel | ||||||
|         'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |         'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, | ||||||
|         'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, |         'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, | ||||||
|         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, |         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, | ||||||
|  |         'subpedido' => \App\Http\Middleware\Subpedido::class, | ||||||
|         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, | ||||||
|         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, | ||||||
|     ]; |     ]; | ||||||
|  |  | ||||||
							
								
								
									
										23
									
								
								app/Http/Middleware/Subpedido.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								app/Http/Middleware/Subpedido.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace App\Http\Middleware; | ||||||
|  | 
 | ||||||
|  | use Closure; | ||||||
|  | 
 | ||||||
|  | class Subpedido | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Handle an incoming request. | ||||||
|  |      * | ||||||
|  |      * @param  \Illuminate\Http\Request  $request | ||||||
|  |      * @param  \Closure  $next | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function handle($request, Closure $next) | ||||||
|  |     { | ||||||
|  |         if (!session('subpedido')) { | ||||||
|  |             return redirect()->route('subpedidos.create'); | ||||||
|  |         } | ||||||
|  |         return $next($request); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										6
									
								
								public/assets/.directory
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								public/assets/.directory
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | ||||||
|  | [Dolphin] | ||||||
|  | HeaderColumnWidths=641,72,95,143 | ||||||
|  | Timestamp=2021,7,28,19,15,55.598 | ||||||
|  | Version=4 | ||||||
|  | ViewMode=1 | ||||||
|  | VisibleRoles=Details_text,Details_type,Details_size,Details_modificationtime,CustomizedDetails | ||||||
							
								
								
									
										
											BIN
										
									
								
								public/assets/logoMPS.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/assets/logoMPS.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 102 KiB | 
							
								
								
									
										48
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | ||||||
|  | window.Event = new Vue(); | ||||||
|  | 
 | ||||||
|  | Vue.component('nav-bar', { | ||||||
|  | 	template: ` | ||||||
|  | 		<nav class="navbar" role="navigation" aria-label="main navigation"> | ||||||
|  |           <div class="navbar-brand"> | ||||||
|  |             <a class="navbar-item" href="https://bulma.io"> | ||||||
|  |               <img src="/assets/logoMPS.png" height="28"> | ||||||
|  |             </a> | ||||||
|  | 
 | ||||||
|  |             <a role="button" class="navbar-burger" :class="{'is-active':isActive}" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample" @click="toggleState"> | ||||||
|  |               <span aria-hidden="true"></span> | ||||||
|  |               <span aria-hidden="true"></span> | ||||||
|  |               <span aria-hidden="true"></span> | ||||||
|  |             </a> | ||||||
|  |           </div> | ||||||
|  | 
 | ||||||
|  |           <div id="navbarBasicExample" class="navbar-menu" :class="{'is-active':isActive}"> | ||||||
|  |             <div class="navbar-start has-text-right-mobile"> | ||||||
|  |                 <!-- Styles nombre del barrio--> | ||||||
|  |                 <p class="navbar-item"><slot name="gdc"></slot></p> | ||||||
|  |                 <a class="navbar-item" | ||||||
|  |                 	onclick="event.preventDefault(); | ||||||
|  |                 	document.getElementById('logout-form').submit();"> | ||||||
|  |                     Cerrar sesión | ||||||
|  |                 </a> | ||||||
|  |                 <slot name="logout-form"></slot> | ||||||
|  |             </div> | ||||||
|  |           </div> | ||||||
|  |         </nav>`, | ||||||
|  | 	data() { | ||||||
|  | 		return { | ||||||
|  | 			isActive: false | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	mounted() { | ||||||
|  | 		console.log("ready"); | ||||||
|  |   	}, | ||||||
|  |   	methods: { | ||||||
|  |   		toggleState() { | ||||||
|  |   			this.isActive = !this.isActive; | ||||||
|  |   		} | ||||||
|  |   	} | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | new Vue({ | ||||||
|  |   el: '#app' | ||||||
|  | }); | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
|     <head> |     <head> | ||||||
|         <meta charset="utf-8"> |         <meta charset="utf-8"> | ||||||
|         <meta name="viewport" content="width=device-width, initial-scale=1"> |         <meta name="viewport" content="width=device-width, initial-scale=1"> | ||||||
|         <title>Compras del MPS</title> |         <title>{{ config('app.name', 'Compras del MPS') }}</title> | ||||||
|         <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"> |         <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"> | ||||||
|     </head> |     </head> | ||||||
|     <body> |     <body> | ||||||
|  |  | ||||||
|  | @ -7,74 +7,32 @@ | ||||||
|     <!-- CSRF Token --> |     <!-- CSRF Token --> | ||||||
|     <meta name="csrf-token" content="{{ csrf_token() }}"> |     <meta name="csrf-token" content="{{ csrf_token() }}"> | ||||||
| 
 | 
 | ||||||
|     <title>{{ config('app.name', 'Laravel') }}</title> |     <title>{{ config('app.name', 'Compras del MPS') }}</title> | ||||||
| 
 | 
 | ||||||
|     <!-- Scripts --> |     <!-- Scripts --> | ||||||
|     <script src="{{ asset('js/app.js') }}" defer></script> |  | ||||||
| 
 | 
 | ||||||
|     <!-- Fonts --> |     <!-- Fonts --> | ||||||
|     <link rel="dns-prefetch" href="//fonts.gstatic.com"> |  | ||||||
|     <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"> |  | ||||||
| 
 | 
 | ||||||
|     <!-- Styles --> |     <!-- Styles --> | ||||||
|     <link href="{{ asset('css/app.css') }}" rel="stylesheet"> |     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"> | ||||||
|  | 
 | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
|     <div id="app"> |     <div id="app"> | ||||||
|         <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm"> |         <nav-bar> | ||||||
|             <div class="container"> |             <template slot="gdc">{{ Auth::user()->name }}</template> | ||||||
|                 <a class="navbar-brand" href="{{ url('/') }}"> |             <template slot="logout-form"> | ||||||
|                     {{ config('app.name', 'Laravel') }} |  | ||||||
|                 </a> |  | ||||||
|                 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"> |  | ||||||
|                     <span class="navbar-toggler-icon"></span> |  | ||||||
|                 </button> |  | ||||||
| 
 |  | ||||||
|                 <div class="collapse navbar-collapse" id="navbarSupportedContent"> |  | ||||||
|                     <!-- Left Side Of Navbar --> |  | ||||||
|                     <ul class="navbar-nav mr-auto"> |  | ||||||
| 
 |  | ||||||
|                     </ul> |  | ||||||
| 
 |  | ||||||
|                     <!-- Right Side Of Navbar --> |  | ||||||
|                     <ul class="navbar-nav ml-auto"> |  | ||||||
|                         <!-- Authentication Links --> |  | ||||||
|                         @guest |  | ||||||
|                             <li class="nav-item"> |  | ||||||
|                                 <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a> |  | ||||||
|                             </li> |  | ||||||
|                             @if (Route::has('register')) |  | ||||||
|                                 <li class="nav-item"> |  | ||||||
|                                     <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a> |  | ||||||
|                                 </li> |  | ||||||
|                             @endif |  | ||||||
|                         @else |  | ||||||
|                             <li class="nav-item dropdown"> |  | ||||||
|                                 <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> |  | ||||||
|                                     {{ Auth::user()->name }} |  | ||||||
|                                 </a> |  | ||||||
| 
 |  | ||||||
|                                 <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> |  | ||||||
|                                     <a class="dropdown-item" href="{{ route('logout') }}" |  | ||||||
|                                        onclick="event.preventDefault();
 |  | ||||||
|                                                      document.getElementById('logout-form').submit();">
 |  | ||||||
|                                         {{ __('Logout') }} |  | ||||||
|                                     </a> |  | ||||||
| 
 |  | ||||||
|                 <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none"> |                 <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none"> | ||||||
|                     @csrf |                     @csrf | ||||||
|                 </form> |                 </form> | ||||||
|                                 </div> |             </template> | ||||||
|                             </li> |         </nav-bar> | ||||||
|                         @endguest |  | ||||||
|                     </ul> |  | ||||||
|                 </div> |  | ||||||
|             </div> |  | ||||||
|         </nav> |  | ||||||
| 
 | 
 | ||||||
|         <main class="py-4"> |         <main class="py-4"> | ||||||
|             @yield('content') |             @yield('content') | ||||||
|         </main> |         </main> | ||||||
|     </div> |     </div> | ||||||
|  |     <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> | ||||||
|  |     <script src="{{ asset('js/app.js') }}" defer></script> | ||||||
| </body> | </body> | ||||||
| </html> | </html> | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								resources/views/subpedidos_create.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								resources/views/subpedidos_create.blade.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | @extends('layouts.app') | ||||||
|  | 
 | ||||||
|  | @section('content') | ||||||
|  | SUBPEDIDOS | ||||||
|  | @endsection | ||||||
|  | @ -16,3 +16,9 @@ use Illuminate\Support\Facades\Route; | ||||||
| Route::get('/', 'ProductoController@index')->name('productos'); | Route::get('/', 'ProductoController@index')->name('productos'); | ||||||
| 
 | 
 | ||||||
| Auth::routes(['register' => false]); | Auth::routes(['register' => false]); | ||||||
|  | 
 | ||||||
|  | Route::get('/productos', 'ProductoController@index')->name('productos.index'); | ||||||
|  | 
 | ||||||
|  | Route::get('/subpedidos', function() { | ||||||
|  | 	return view('subpedidos_create'); | ||||||
|  | })->name('subpedidos.create')->middleware('auth'); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 nat
						nat