Skip to content

Commit 1099df0

Browse files
committedOct 31, 2021
v1
1 parent 19ae92d commit 1099df0

11 files changed

+350
-18
lines changed
 

Diff for: ‎DATABASE_STRUCT.sql

+323
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 4.8.5
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Servidor: 127.0.0.1
6+
-- Tiempo de generación: 31-10-2021 a las 18:27:40
7+
-- Versión del servidor: 10.1.38-MariaDB
8+
-- Versión de PHP: 7.3.2
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
SET AUTOCOMMIT = 0;
12+
START TRANSACTION;
13+
SET time_zone = "+00:00";
14+
15+
16+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19+
/*!40101 SET NAMES utf8mb4 */;
20+
21+
--
22+
-- Base de datos: `restaurant_orders`
23+
--
24+
25+
-- --------------------------------------------------------
26+
27+
--
28+
-- Estructura de tabla para la tabla `categories`
29+
--
30+
31+
CREATE TABLE `categories` (
32+
`id` bigint(20) UNSIGNED NOT NULL,
33+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
34+
`description` longtext COLLATE utf8mb4_unicode_ci,
35+
`created_at` timestamp NULL DEFAULT NULL,
36+
`updated_at` timestamp NULL DEFAULT NULL
37+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
38+
39+
-- --------------------------------------------------------
40+
41+
--
42+
-- Estructura de tabla para la tabla `clients`
43+
--
44+
45+
CREATE TABLE `clients` (
46+
`id` bigint(20) UNSIGNED NOT NULL,
47+
`id_order` bigint(20) UNSIGNED NOT NULL,
48+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
49+
`notes` longtext COLLATE utf8mb4_unicode_ci,
50+
`created_at` timestamp NULL DEFAULT NULL,
51+
`updated_at` timestamp NULL DEFAULT NULL
52+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
53+
54+
-- --------------------------------------------------------
55+
56+
--
57+
-- Estructura de tabla para la tabla `failed_jobs`
58+
--
59+
60+
CREATE TABLE `failed_jobs` (
61+
`id` bigint(20) UNSIGNED NOT NULL,
62+
`uuid` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
63+
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
64+
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
65+
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
66+
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
67+
`failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
68+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
69+
70+
-- --------------------------------------------------------
71+
72+
--
73+
-- Estructura de tabla para la tabla `migrations`
74+
--
75+
76+
CREATE TABLE `migrations` (
77+
`id` int(10) UNSIGNED NOT NULL,
78+
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
79+
`batch` int(11) NOT NULL
80+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
81+
82+
--
83+
-- Volcado de datos para la tabla `migrations`
84+
--
85+
86+
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
87+
(1, '2014_10_12_000000_create_users_table', 1),
88+
(2, '2014_10_12_100000_create_password_resets_table', 1),
89+
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
90+
(4, '2019_12_14_000001_create_personal_access_tokens_table', 1),
91+
(5, '2021_10_26_164220_create_categories_table', 1),
92+
(6, '2021_10_26_175345_create_products_table', 1),
93+
(7, '2021_10_26_194055_create_clients_table', 1),
94+
(8, '2021_10_27_000115_create_orders_table', 1);
95+
96+
-- --------------------------------------------------------
97+
98+
--
99+
-- Estructura de tabla para la tabla `orders`
100+
--
101+
102+
CREATE TABLE `orders` (
103+
`id` bigint(20) UNSIGNED NOT NULL,
104+
`id_order` bigint(20) UNSIGNED NOT NULL,
105+
`id_client` bigint(20) UNSIGNED NOT NULL,
106+
`id_product` bigint(20) UNSIGNED NOT NULL,
107+
`quantity` bigint(20) UNSIGNED NOT NULL,
108+
`status` bigint(20) UNSIGNED NOT NULL,
109+
`created_at` timestamp NULL DEFAULT NULL,
110+
`updated_at` timestamp NULL DEFAULT NULL
111+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
112+
113+
-- --------------------------------------------------------
114+
115+
--
116+
-- Estructura de tabla para la tabla `password_resets`
117+
--
118+
119+
CREATE TABLE `password_resets` (
120+
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
121+
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
122+
`created_at` timestamp NULL DEFAULT NULL
123+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
124+
125+
-- --------------------------------------------------------
126+
127+
--
128+
-- Estructura de tabla para la tabla `personal_access_tokens`
129+
--
130+
131+
CREATE TABLE `personal_access_tokens` (
132+
`id` bigint(20) UNSIGNED NOT NULL,
133+
`tokenable_type` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
134+
`tokenable_id` bigint(20) UNSIGNED NOT NULL,
135+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
136+
`token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
137+
`abilities` text COLLATE utf8mb4_unicode_ci,
138+
`last_used_at` timestamp NULL DEFAULT NULL,
139+
`created_at` timestamp NULL DEFAULT NULL,
140+
`updated_at` timestamp NULL DEFAULT NULL
141+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
142+
143+
-- --------------------------------------------------------
144+
145+
--
146+
-- Estructura de tabla para la tabla `products`
147+
--
148+
149+
CREATE TABLE `products` (
150+
`id` bigint(20) UNSIGNED NOT NULL,
151+
`id_category` bigint(20) UNSIGNED NOT NULL,
152+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
153+
`description` longtext COLLATE utf8mb4_unicode_ci,
154+
`price` decimal(15,2) NOT NULL,
155+
`stock` tinyint(1) NOT NULL DEFAULT '1',
156+
`created_at` timestamp NULL DEFAULT NULL,
157+
`updated_at` timestamp NULL DEFAULT NULL
158+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
159+
160+
-- --------------------------------------------------------
161+
162+
--
163+
-- Estructura de tabla para la tabla `users`
164+
--
165+
166+
CREATE TABLE `users` (
167+
`id` bigint(20) UNSIGNED NOT NULL,
168+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
169+
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
170+
`active` tinyint(1) DEFAULT '0',
171+
`role` int(11) NOT NULL DEFAULT '10',
172+
`email_verified_at` timestamp NULL DEFAULT NULL,
173+
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
174+
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
175+
`created_at` timestamp NULL DEFAULT NULL,
176+
`updated_at` timestamp NULL DEFAULT NULL
177+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
178+
179+
--
180+
-- Volcado de datos para la tabla `users`
181+
--
182+
183+
INSERT INTO `users` (`id`, `name`, `email`, `active`, `role`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
184+
(1, 'Administrador', 'admin@admin.com', 1, 0, NULL, '$2y$10$qIB9496fj6yYqMs1xbkiKOXQyIRytoO9RhgmlqFw/lpBpJ24xJlwC', NULL, '2021-10-31 16:26:36', '2021-10-31 16:26:36');
185+
186+
--
187+
-- Índices para tablas volcadas
188+
--
189+
190+
--
191+
-- Indices de la tabla `categories`
192+
--
193+
ALTER TABLE `categories`
194+
ADD PRIMARY KEY (`id`);
195+
196+
--
197+
-- Indices de la tabla `clients`
198+
--
199+
ALTER TABLE `clients`
200+
ADD PRIMARY KEY (`id`);
201+
202+
--
203+
-- Indices de la tabla `failed_jobs`
204+
--
205+
ALTER TABLE `failed_jobs`
206+
ADD PRIMARY KEY (`id`),
207+
ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);
208+
209+
--
210+
-- Indices de la tabla `migrations`
211+
--
212+
ALTER TABLE `migrations`
213+
ADD PRIMARY KEY (`id`);
214+
215+
--
216+
-- Indices de la tabla `orders`
217+
--
218+
ALTER TABLE `orders`
219+
ADD PRIMARY KEY (`id`),
220+
ADD KEY `orders_id_client_foreign` (`id_client`),
221+
ADD KEY `orders_id_product_foreign` (`id_product`);
222+
223+
--
224+
-- Indices de la tabla `password_resets`
225+
--
226+
ALTER TABLE `password_resets`
227+
ADD KEY `password_resets_email_index` (`email`);
228+
229+
--
230+
-- Indices de la tabla `personal_access_tokens`
231+
--
232+
ALTER TABLE `personal_access_tokens`
233+
ADD PRIMARY KEY (`id`),
234+
ADD UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
235+
ADD KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`);
236+
237+
--
238+
-- Indices de la tabla `products`
239+
--
240+
ALTER TABLE `products`
241+
ADD PRIMARY KEY (`id`),
242+
ADD KEY `products_id_category_foreign` (`id_category`);
243+
244+
--
245+
-- Indices de la tabla `users`
246+
--
247+
ALTER TABLE `users`
248+
ADD PRIMARY KEY (`id`),
249+
ADD UNIQUE KEY `users_email_unique` (`email`);
250+
251+
--
252+
-- AUTO_INCREMENT de las tablas volcadas
253+
--
254+
255+
--
256+
-- AUTO_INCREMENT de la tabla `categories`
257+
--
258+
ALTER TABLE `categories`
259+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
260+
261+
--
262+
-- AUTO_INCREMENT de la tabla `clients`
263+
--
264+
ALTER TABLE `clients`
265+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
266+
267+
--
268+
-- AUTO_INCREMENT de la tabla `failed_jobs`
269+
--
270+
ALTER TABLE `failed_jobs`
271+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
272+
273+
--
274+
-- AUTO_INCREMENT de la tabla `migrations`
275+
--
276+
ALTER TABLE `migrations`
277+
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
278+
279+
--
280+
-- AUTO_INCREMENT de la tabla `orders`
281+
--
282+
ALTER TABLE `orders`
283+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
284+
285+
--
286+
-- AUTO_INCREMENT de la tabla `personal_access_tokens`
287+
--
288+
ALTER TABLE `personal_access_tokens`
289+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
290+
291+
--
292+
-- AUTO_INCREMENT de la tabla `products`
293+
--
294+
ALTER TABLE `products`
295+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
296+
297+
--
298+
-- AUTO_INCREMENT de la tabla `users`
299+
--
300+
ALTER TABLE `users`
301+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
302+
303+
--
304+
-- Restricciones para tablas volcadas
305+
--
306+
307+
--
308+
-- Filtros para la tabla `orders`
309+
--
310+
ALTER TABLE `orders`
311+
ADD CONSTRAINT `orders_id_client_foreign` FOREIGN KEY (`id_client`) REFERENCES `clients` (`id`) ON DELETE CASCADE,
312+
ADD CONSTRAINT `orders_id_product_foreign` FOREIGN KEY (`id_product`) REFERENCES `products` (`id`) ON DELETE CASCADE;
313+
314+
--
315+
-- Filtros para la tabla `products`
316+
--
317+
ALTER TABLE `products`
318+
ADD CONSTRAINT `products_id_category_foreign` FOREIGN KEY (`id_category`) REFERENCES `categories` (`id`) ON DELETE CASCADE;
319+
COMMIT;
320+
321+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
322+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
323+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Diff for: ‎app/Http/Controllers/Auth/RegisterController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function validator(array $data)
5252
return Validator::make($data, [
5353
'name' => ['required', 'string', 'max:255'],
5454
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
55-
'password' => ['required', 'string', 'min:8', 'confirmed'],
55+
'password' => ['required', 'string', 'min:5', 'confirmed'],
5656
]);
5757
}
5858

Diff for: ‎app/Http/Controllers/CategoryController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ public function destroy($id)
129129
}
130130
$category = Category::find($id)->delete();
131131
return redirect()->route('categories.index')
132-
->with('success', 'Categoría elimnada con éxito.');
132+
->with('success', 'Categoría eliminada con éxito.');
133133
}
134134
}

Diff for: ‎app/Http/Controllers/OrderController.php

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public function __construct()
2727
*/
2828
public function index()
2929
{
30+
if (auth()->user()->active == 0){
31+
return redirect()->route('home')
32+
->with('error', 'Su cuenta no está activada.');
33+
}
3034
$orders = Order::orderBy('id', 'DESC')->paginate();
3135
return view('order.index', compact('orders'))
3236
->with('i', (request()->input('page', 1) - 1) * $orders->perPage());

Diff for: ‎app/Http/Controllers/ProductController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public function __construct()
2323
*/
2424
public function index()
2525
{
26-
if (auth()->user()->role > 1){
26+
if ((auth()->user()->role > 1) || (auth()->user()->active == 0) ){
2727
return redirect()->route('home')
28-
->with('error', 'No tiene permisos para realizar esta operación.');
28+
->with('error', 'Su cuenta no está activada.');
2929
}
3030
$products = Product::paginate();
3131
return view('product.index', compact('products'))

0 commit comments

Comments
 (0)
Please sign in to comment.