· 8 years ago · Mar 13, 2018, 10:20 AM
1<?php
2
3namespace AppHttpControllersAdmin;
4use IlluminateHttpRequest;
5use AppHttpControllersController;
6use AppCategory;
7use IlluminateSupportFacadesInput;
8use IlluminateSupportFacadesRedirect;
9use IlluminateSupportFacadesAuth;
10
11class AdminController extends Controller
12{
13 public function show()
14 {
15 return view('admin/admin');
16
17 // echo "here";
18 }
19
20 public function addCategory()
21 {
22 $category=new Category;
23 $category->category_name = Input::get('category');
24
25 $category->save();
26 dd("2");
27
28 //return view('admin');
29 }
30
31}
32
33<!DOCTYPE html>
34<head>
35 <meta charset="utf-8">
36 <meta name="viewport" content="width=device-width, initial-scale=1">
37 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
38 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
39 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
40 <style>
41 .bod{
42 background-color:#f8f8f8;
43 border-shadow: 5px 10px 20px white inset;
44 border-width:5px;
45 margin-top:-12px;
46 }
47 .h1{
48 font-family:"Book Antiqua";
49 font-size: 90px;
50 color: red;
51 text-align: center;
52 }
53 div {
54 border-radius: 5px;
55 /*background-color: #f2f2f2;*/
56 /*background-color: #7CA8C1 ;*/
57 padding: 20px;
58 position: relative;
59 /*border:2px solid white;*/
60 height: 200px;
61 width: 50%;
62 }
63 </style>
64</head>
65<body class="bod">
66<h1 class="h1">Admin</h1>
67<div align="left">
68 <form action="{{ route('addCategory') }}" method="get">
69 {{ csrf_field() }}
70 <label for="category" style="font-family: 'Book Antiqua';font-size: 48px">Category</label> <br/>
71 <input type="text" name="category" id="category" placeholder="Enter the Category" style="width: 25%;height:35px; border:2px solid floralwhite">
72 <input type="submit" name="add" id="add" value="ADD">
73 </form>
74</div>
75</body>
76</html>
77
78Route::get('/addCategory','AdminAdminController@addCategory')->name('addCategory');
79
80<?php
81
82namespace App;
83
84use IlluminateDatabaseEloquentModel;
85
86class Category extends Model
87{
88 //
89
90 protected $fillable = [
91 'category_name',
92 ];
93
94}
95
96-- phpMyAdmin SQL Dump
97-- version 4.7.4
98-- https://www.phpmyadmin.net/
99--
100-- Host: 127.0.0.1:3306
101-- Generation Time: Mar 13, 2018 at 10:12 AM
102-- Server version: 5.7.19
103-- PHP Version: 5.6.31
104
105SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
106SET AUTOCOMMIT = 0;
107START TRANSACTION;
108SET time_zone = "+00:00";
109
110
111/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
112/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
113/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
114/*!40101 SET NAMES utf8mb4 */;
115
116--
117-- Database: `mydb`
118--
119
120-- --------------------------------------------------------
121
122--
123-- Table structure for table `category`
124--
125
126DROP TABLE IF EXISTS `category`;
127CREATE TABLE IF NOT EXISTS `category` (
128 `category_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
129 `category_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
130 `created_at` timestamp NULL DEFAULT NULL,
131 `updated_at` timestamp NULL DEFAULT NULL,
132 PRIMARY KEY (`category_id`)
133) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
134COMMIT;
135
136/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
137/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
138/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
139
140protected $table = "Categories";