Big update for category controller - for admin panel
This commit is contained in:
		
							
								
								
									
										49
									
								
								resources/views/dashboard/categories/create.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								resources/views/dashboard/categories/create.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| @extends('layout.app') | ||||
| @section('title', 'Utwórz kategorię') | ||||
|  | ||||
| @section('main') | ||||
| @if (\Session::has('message')) | ||||
|     <span>{{ \Session::get('message') }}</span> | ||||
| @endif | ||||
| @if ($errors->any()) | ||||
|     <div class="alert alert-danger"> | ||||
|         <ul> | ||||
|             @foreach ($errors->all() as $error) | ||||
|                 <li>{{ $error }}</li> | ||||
|             @endforeach | ||||
|         </ul> | ||||
|     </div> | ||||
| @endif | ||||
| <form class="form" method="POST" action="{{ route('admin.category.store') }}"> | ||||
|     @csrf | ||||
|  | ||||
|     <label for="name">Nazwa kategorii</label> | ||||
|     <input id="name" type="text" name="name" value="{{ old('name') }}" placeholder="Nazwa"> | ||||
|     @error('name') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="slug">Slug (opcjonalny)</label> | ||||
|     <input id="slug" type="text" name="slug" value="{{ old('slug') }}" placeholder="Slug"> | ||||
|     @error('slug') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="priority">Priority</label> | ||||
|     <input id="priority" type="number" name="priority" value="{{ old('priority', 0) }}" min="0"> | ||||
|     @error('name') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="default">Default</label> | ||||
|     <input id="default" type="checkbox" name="default" {{ old('default') != 0 ? 'checked' : '' }}> | ||||
|  | ||||
|     <label for="visible">Visible</label> | ||||
|     <input id="visible" type="checkbox" name="visible" {{ old('default') != 0 ? 'checked' : '' }}> | ||||
|  | ||||
|     <input type="submit" value="Utwórz"> | ||||
| </form> | ||||
| <div> | ||||
|     <a href="{{ route('admin.home') }}"><< Cofnij</a> | ||||
| </div> | ||||
| @endsection | ||||
							
								
								
									
										14
									
								
								resources/views/dashboard/categories/delete.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								resources/views/dashboard/categories/delete.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| @extends('layout.app') | ||||
| @section('title', 'Login') | ||||
|  | ||||
| @section('main') | ||||
| <form method="POST" action="{{ route('admin.category.destroy', compact('category')) }}"> | ||||
|     @method('DELETE') | ||||
|     @csrf | ||||
|     Czy jesteś pewien, że chcesz usunąć kategorię "{{ $category->name .' - '. $category->slug }}"? | ||||
|     <input type="submit" value="Tak, usuń!"> | ||||
| </form> | ||||
| <div> | ||||
|     <a href="{{ route('admin.category.edit', compact('category')) }}"><< Cofnij</a> | ||||
| </div> | ||||
| @endsection | ||||
							
								
								
									
										53
									
								
								resources/views/dashboard/categories/edit.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								resources/views/dashboard/categories/edit.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| @extends('layout.app') | ||||
| @section('title', 'Login') | ||||
|  | ||||
| @section('main') | ||||
| @if (\Session::has('message')) | ||||
|     <span>{{ \Session::get('message') }}</span> | ||||
| @endif | ||||
| @if ($errors->any()) | ||||
|     <div class="alert alert-danger"> | ||||
|         <ul> | ||||
|             @foreach ($errors->all() as $error) | ||||
|                 <li>{{ $error }}</li> | ||||
|             @endforeach | ||||
|         </ul> | ||||
|     </div> | ||||
| @endif | ||||
| <form class="form" method="POST" action="{{ route('admin.category.update', ['category' => $category]) }}"> | ||||
|     @method('PUT') | ||||
|     @csrf | ||||
|  | ||||
|     <label for="name">Nazwa kategorii</label> | ||||
|     <input id="name" type="text" name="name" value="{{ old('name', $category->name) }}" placeholder="Nazwa"> | ||||
|     @error('name') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="slug">Slug (opcjonalny)</label> | ||||
|     <input id="slug" type="text" name="slug" value="{{ old('slug', $category->slug) }}" placeholder="Slug"> | ||||
|     @error('slug') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="priority">Priority</label> | ||||
|     <input id="priority" type="number" name="priority" value="{{ old('priority', $category->priority) }}" min="0"> | ||||
|     @error('priority') | ||||
|     <span class="error">{{ $message }}</span> | ||||
|     @enderror | ||||
|  | ||||
|     <label for="default">Default</label> | ||||
|     <input id="default" type="checkbox" | ||||
|         name="default" {{ old('default', $category->default) != 0 ? 'checked' : '' }}> | ||||
|  | ||||
|     <label for="visible">Visible</label> | ||||
|     <input id="visible" type="checkbox" | ||||
|         name="visible" {{ old('visible', $category->visible) != 0 ? 'checked' : '' }}> | ||||
|  | ||||
|     <input type="submit" value="Edytuj"> | ||||
| </form> | ||||
| <div> | ||||
|     <a href="{{ route('admin.category.delete', compact('category')) }}">USUŃ!</a><br> | ||||
|     <a href="{{ route('admin.home') }}"><< Cofnij</a> | ||||
| </div> | ||||
| @endsection | ||||
							
								
								
									
										11
									
								
								resources/views/dashboard/categories/list.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/views/dashboard/categories/list.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <div class="categories"> | ||||
|     <header><h1>Kategorie</h1></header> | ||||
|     <a href="{{ route('admin.category.create') }}"> | ||||
|         <button>Utwórz nową kategorię</button> | ||||
|     </a> | ||||
|     <ul class="category_items"> | ||||
|     @foreach ($categories as $category) | ||||
|         <li class="project_element">{{ $category->name }} | <a href="{{ route('admin.category.edit', ['category' => $category->id]) }}">Edytuj</a></li> | ||||
|     @endforeach | ||||
|     <ul> | ||||
| </div> | ||||
| @@ -1,6 +1,23 @@ | ||||
| @extends('layout.app') | ||||
| @section('title', 'Dashboard') | ||||
|  | ||||
| @section('main') | ||||
| @push('styles') | ||||
| <style> | ||||
|     #main { | ||||
|         display: grid; | ||||
|         grid-template-columns: repeat(3, 1fr); | ||||
|         column-gap: 1em; | ||||
|     } | ||||
|     #main .projects { | ||||
|         grid-column: 1 / 3; | ||||
|     } | ||||
| </style> | ||||
| @endpush | ||||
|  | ||||
| @section('main') | ||||
| @if(\Session::has('message')) | ||||
|     <span>{{ \Session::get('message') }}</span> | ||||
| @endif | ||||
| @include('dashboard.projects.list') | ||||
| @include('dashboard.categories.list') | ||||
| @endsection | ||||
|   | ||||
							
								
								
									
										11
									
								
								resources/views/dashboard/projects/list.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/views/dashboard/projects/list.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <div class="projects"> | ||||
|     <header><h1>Projekty</h1></header> | ||||
|     <a href="{{ route('admin.category.create') }}"> | ||||
|         <button>Utwórz nowy projekt</button> | ||||
|     </a> | ||||
|     <ul class="project_items"> | ||||
|     @foreach ($projects as $project) | ||||
|         <li class="project_element">{{ $project->title }} | <a href="{{ route('admin.category.edit', ['category' => $project->id]) }}">Edytuj</a></li> | ||||
|     @endforeach | ||||
|     <ul> | ||||
| </div> | ||||
| @@ -11,6 +11,7 @@ | ||||
|  | ||||
|         <!-- Styles --> | ||||
|         <link href="{{ asset('css/app.css') }}" rel="stylesheet"> | ||||
|         @stack('styles') | ||||
|     </head> | ||||
|     <body class="antialiased"> | ||||
|         <main id="main"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user