├── public ├── favicon.ico ├── robots.txt ├── mix-manifest.json ├── images │ └── screenshots │ │ ├── cart.png │ │ ├── home.png │ │ ├── food_details.png │ │ ├── order_history.png │ │ ├── admin_add_food.png │ │ ├── admin_view_food.png │ │ └── admin_update_food.png ├── .htaccess └── index.php ├── database ├── .gitignore ├── seeders │ ├── FoodTableSeeder.php │ ├── UserTableSeeder.php │ ├── OrderTableSeeder.php │ ├── DatabaseSeeder.php │ └── FoodOrderTableSeeder.php ├── factories │ ├── OrderFactory.php │ ├── FoodFactory.php │ └── UserFactory.php └── migrations │ ├── 2022_04_05_055944_change_picture_column.php │ ├── 2022_04_05_061005_change_food_name_unique.php │ ├── 2022_04_10_060818_add_primary_key_to_food_order.php │ ├── 2022_04_10_175159_change_food_price_to_double.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2022_02_27_193758_food.php │ ├── 2022_04_07_194813_change_delivery_address_column_to_nullable_in_order_table.php │ ├── 2022_02_27_202353_order.php │ ├── 2022_02_27_204135_food_order.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2014_10_12_000000_create_users_table.php │ └── 2019_12_14_000001_create_personal_access_tokens_table.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── resources ├── css │ └── app.css ├── sass │ ├── _variables.scss │ └── app.scss ├── views │ ├── layouts │ │ ├── admin.blade.php │ │ └── auth.blade.php │ ├── auth │ │ ├── verify.blade.php │ │ ├── passwords │ │ │ ├── email.blade.php │ │ │ ├── confirm.blade.php │ │ │ └── reset.blade.php │ │ ├── login.blade.php │ │ └── register.blade.php │ ├── components │ │ └── flash_message.blade.php │ ├── food │ │ ├── viewfood.blade.php │ │ ├── show.blade.php │ │ ├── home.blade.php │ │ ├── addfood.blade.php │ │ └── updatefood.blade.php │ ├── editUser.blade.php │ └── order.blade.php ├── lang │ └── en │ │ ├── pagination.php │ │ ├── auth.php │ │ ├── passwords.php │ │ └── validation.php └── js │ ├── components │ └── ExampleComponent.vue │ ├── bootstrap.js │ └── app.js ├── .gitattributes ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ └── ExampleTest.php └── CreatesApplication.php ├── tailwind.config.js ├── .styleci.yml ├── .gitignore ├── .editorconfig ├── app ├── Http │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── TrustHosts.php │ │ ├── TrimStrings.php │ │ ├── Authenticate.php │ │ ├── TrustProxies.php │ │ ├── checkAdmin.php │ │ └── RedirectIfAuthenticated.php │ ├── Controllers │ │ ├── Controller.php │ │ ├── HomeController.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── ResetPasswordController.php │ │ │ ├── ConfirmPasswordController.php │ │ │ ├── VerificationController.php │ │ │ ├── LoginController.php │ │ │ └── RegisterController.php │ │ ├── UserController.php │ │ ├── FoodController.php │ │ └── OrderController.php │ └── Kernel.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AppServiceProvider.php │ ├── EventServiceProvider.php │ ├── AuthServiceProvider.php │ └── RouteServiceProvider.php ├── View │ └── Components │ │ └── Footer.php ├── Exceptions │ └── Handler.php ├── Console │ └── Kernel.php ├── Models │ ├── Food.php │ ├── Order.php │ └── User.php └── Policies │ └── FoodPolicy.php ├── routes ├── channels.php ├── console.php ├── api.php └── web.php ├── server.php ├── webpack.mix.js ├── package.json ├── config ├── cors.php ├── services.php ├── view.php ├── hashing.php ├── broadcasting.php ├── sanctum.php ├── filesystems.php ├── queue.php ├── cache.php ├── logging.php ├── mail.php ├── auth.php ├── database.php ├── session.php └── app.php ├── phpunit.xml ├── artisan ├── composer.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /public/images/screenshots/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/cart.png -------------------------------------------------------------------------------- /public/images/screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/home.png -------------------------------------------------------------------------------- /public/images/screenshots/food_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/food_details.png -------------------------------------------------------------------------------- /public/images/screenshots/order_history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/order_history.png -------------------------------------------------------------------------------- /public/images/screenshots/admin_add_food.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/admin_add_food.png -------------------------------------------------------------------------------- /public/images/screenshots/admin_view_food.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/admin_view_food.png -------------------------------------------------------------------------------- /public/images/screenshots/admin_update_food.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonchn18/laravel-food-ordering-web-app/HEAD/public/images/screenshots/admin_update_food.png -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | // Body 2 | $body-bg: #f8fafc; 3 | 4 | // Typography 5 | $font-family-sans-serif: 'Nunito', sans-serif; 6 | $font-size-base: 0.9rem; 7 | $line-height-base: 1.6; 8 | -------------------------------------------------------------------------------- /resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // Fonts 2 | @import url('https://fonts.googleapis.com/css?family=Nunito'); 3 | 4 | // Variables 5 | @import 'variables'; 6 | 7 | // Bootstrap 8 | @import '~bootstrap/scss/bootstrap'; 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /database/seeders/FoodTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /database/seeders/UserTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /database/seeders/OrderTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts() 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | call([ 17 | UserTableSeeder::class, 18 | FoodTableSeeder::class, 19 | OrderTableSeeder::class, 20 | FoodOrderTableSeeder::class, 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/views/layouts/admin.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('content') 3 |
4 |
5 |
6 |
7 |
Dashboard
8 |
9 | ONLY ADMIN PRIVILEGES CAN ACCESS THIS PAGE! 10 |
11 |
12 |
13 |
14 |
15 | @endsection -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Contracts\Support\Renderable 23 | */ 24 | public function index() 25 | { 26 | return view('home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/View/Components/Footer.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /database/factories/OrderFactory.php: -------------------------------------------------------------------------------- 1 | \App\Models\User::all()->random()->id, 18 | 'date' => $this->faker->date(), 19 | 'type' => $this->faker->randomElement(['pickup', 'delivery']), 20 | 'deliveryAddress' => $this->faker->address(), 21 | ]; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /resources/js/components/ExampleComponent.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 12 | return response()->json(['error' => 'Unauthenticated.'], 401); 13 | } 14 | if ($request->is('admin') || $request->is('admin/*')) { 15 | return redirect()->guest('/login/admin'); 16 | } 17 | return redirect()->guest(route('login')); 18 | } 19 | } -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 19 | return $request->user(); 20 | }); 21 | -------------------------------------------------------------------------------- /database/seeders/FoodOrderTableSeeder.php: -------------------------------------------------------------------------------- 1 | random(10); 17 | $food = \App\Models\Food::all()->random(10); 18 | $orders->each(function (\App\Models\Order $r) use ($food) { 19 | $r->food()->attach( 20 | $food->random(rand(1, 5))->pluck('id')->toArray(), 21 | ['quantity' => rand(1, 5)] 22 | ); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/migrations/2022_04_05_055944_change_picture_column.php: -------------------------------------------------------------------------------- 1 | string('picture')->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .vue() 16 | .sass('resources/sass/app.scss', 'public/css') 17 | .postCss("resources/css/app.css", "public/css", [ 18 | require("tailwindcss"), 19 | ]); 20 | -------------------------------------------------------------------------------- /database/migrations/2022_04_05_061005_change_food_name_unique.php: -------------------------------------------------------------------------------- 1 | string('name')->unique()->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'password' => 'The provided password is incorrect.', 18 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 19 | } 20 | 21 | /** 22 | * Register the commands for the application. 23 | * 24 | * @return void 25 | */ 26 | protected function commands() 27 | { 28 | $this->load(__DIR__.'/Commands'); 29 | 30 | require base_path('routes/console.php'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Models/Food.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | protected $fillable = [ 27 | 'name', 28 | 'price', 29 | 'description', 30 | 'type', 31 | 'picture', 32 | ]; 33 | 34 | public function orders() { 35 | return $this->belongsToMany(Order::class)->withPivot('quantity'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2022_04_10_060818_add_primary_key_to_food_order.php: -------------------------------------------------------------------------------- 1 | primary(['order_id', 'food_id'])->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('food_order', function (Blueprint $table) { 29 | // 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2022_04_10_175159_change_food_price_to_double.php: -------------------------------------------------------------------------------- 1 | float('price')->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('food', function (Blueprint $table) { 29 | $table->float('price')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/factories/FoodFactory.php: -------------------------------------------------------------------------------- 1 | faker->addProvider(new \FakerRestaurant\Provider\en_US\Restaurant($this->faker)); 19 | return [ 20 | 'name' => $this->faker->unique()->foodName(), 21 | 'price' => $this->faker->numberBetween(5, 20), 22 | 'description' => $this->faker->sentence(6, true), 23 | 'type' => $this->faker->randomElement(['Western', 'Chinese', 'Japanese']), 24 | 'picture' => $this->faker->imageUrl(640, 480), 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2022_02_27_193758_food.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('price'); 20 | $table->string('description'); 21 | $table->string('type'); 22 | $table->binary('picture'); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('food'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Models/Order.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | protected $fillable = [ 27 | 'user_id', 28 | 'date', 29 | 'type', 30 | 'deliveryAddress', 31 | ]; 32 | 33 | public function user() { 34 | return $this->belongsTo(User::class); 35 | } 36 | 37 | public function food() { 38 | return $this->belongsToMany(Food::class)->withPivot('quantity'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Http/Middleware/checkAdmin.php: -------------------------------------------------------------------------------- 1 | check() && $request-> user()->isAdmin) { 21 | return $next($request); 22 | } 23 | session()->flash('unauthorized', 'You are not authorized to access the page '.$request->path()); 24 | return redirect('../home'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /database/migrations/2022_04_07_194813_change_delivery_address_column_to_nullable_in_order_table.php: -------------------------------------------------------------------------------- 1 | string('deliveryAddress')->nullable()->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('order', function (Blueprint $table) { 29 | $table->string('deliveryAddress')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "mix", 6 | "watch": "mix watch", 7 | "watch-poll": "mix watch -- --watch-options-poll=1000", 8 | "hot": "mix watch --hot", 9 | "prod": "npm run production", 10 | "production": "mix --production" 11 | }, 12 | "devDependencies": { 13 | "@popperjs/core": "^2.10.2", 14 | "autoprefixer": "^10.4.4", 15 | "axios": "^0.21", 16 | "bootstrap": "^5.1.3", 17 | "laravel-mix": "^6.0.6", 18 | "lodash": "^4.17.19", 19 | "postcss": "^8.4.12", 20 | "resolve-url-loader": "^3.1.2", 21 | "sass": "^1.32.11", 22 | "sass-loader": "^11.0.1", 23 | "tailwindcss": "^3.0.23", 24 | "vue": "^2.6.12", 25 | "vue-loader": "^15.9.8", 26 | "vue-template-compiler": "^2.6.12" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /database/migrations/2022_02_27_202353_order.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->integer('user_id'); 19 | $table->foreign('user_id')->references('id')->on('user')->onDelete('cascade'); 20 | $table->dateTime('date'); 21 | $table->string('type'); 22 | $table->string('deliveryAddress'); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('order'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | integer('order_id'); 18 | $table->integer('food_id'); 19 | $table->integer('quantity'); 20 | $table->foreign('order_id')->references('id')->on('order')->onDelete('cascade'); 21 | $table->foreign('food_id')->references('id')->on('food')->onDelete('cascade'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('food_order'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 23 | return redirect('/admin'); 24 | } 25 | 26 | if (Auth::guard($guard)->check()) { 27 | return redirect('/home'); 28 | } 29 | return $next($request); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('uuid')->unique(); 19 | $table->text('connection'); 20 | $table->text('queue'); 21 | $table->longText('payload'); 22 | $table->longText('exception'); 23 | $table->timestamp('failed_at')->useCurrent(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('failed_jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | try { 4 | require('bootstrap'); 5 | } catch (e) {} 6 | 7 | /** 8 | * We'll load the axios HTTP library which allows us to easily issue requests 9 | * to our Laravel back-end. This library automatically handles sending the 10 | * CSRF token as a header based on the value of the "XSRF" token cookie. 11 | */ 12 | 13 | window.axios = require('axios'); 14 | 15 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 16 | 17 | /** 18 | * Echo exposes an expressive API for subscribing to channels and listening 19 | * for events that are broadcast by Laravel. Echo and event broadcasting 20 | * allows your team to easily build robust real-time web applications. 21 | */ 22 | 23 | // import Echo from 'laravel-echo'; 24 | 25 | // window.Pusher = require('pusher-js'); 26 | 27 | // window.Echo = new Echo({ 28 | // broadcaster: 'pusher', 29 | // key: process.env.MIX_PUSHER_APP_KEY, 30 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 31 | // forceTLS: true 32 | // }); 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->boolean('isAdmin')->default(false); 22 | $table->string('password'); 23 | $table->string('address'); 24 | $table->rememberToken(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('users'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->morphs('tokenable'); 19 | $table->string('name'); 20 | $table->string('token', 64)->unique(); 21 | $table->text('abilities')->nullable(); 22 | $table->timestamp('last_used_at')->nullable(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('personal_access_tokens'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | protected $policies = [ 18 | // 'App\Models\Model' => 'App\Policies\ModelPolicy', 19 | Food::class => FoodPolicy::class, 20 | 21 | ]; 22 | 23 | /** 24 | * Register any authentication / authorization services. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | $this->registerPolicies(); 31 | 32 | // Define an admin role 33 | Gate::define('isAdmin', function($user) { 34 | return $user->isAdmin == 1; 35 | }); 36 | 37 | // Define a user role 38 | Gate::define('isUser', function($user) { 39 | return $user->isAdmin == 0; 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->name(), 19 | 'email' => $this->faker->unique()->safeEmail(), 20 | 'email_verified_at' => now(), 21 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 22 | 'remember_token' => Str::random(10), 23 | 'address' => $this->faker->address(), 24 | ]; 25 | } 26 | 27 | /** 28 | * Indicate that the model's email address should be unverified. 29 | * 30 | * @return \Illuminate\Database\Eloquent\Factories\Factory 31 | */ 32 | public function unverified() 33 | { 34 | return $this->state(function (array $attributes) { 35 | return [ 36 | 'email_verified_at' => null, 37 | ]; 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ConfirmPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * First we will load all of this project's JavaScript dependencies which 3 | * includes Vue and other libraries. It is a great starting point when 4 | * building robust, powerful web applications using Vue and Laravel. 5 | */ 6 | 7 | require('./bootstrap'); 8 | 9 | window.Vue = require('vue').default; 10 | 11 | /** 12 | * The following block of code may be used to automatically register your 13 | * Vue components. It will recursively scan this directory for the Vue 14 | * components and automatically register them with their "basename". 15 | * 16 | * Eg. ./components/ExampleComponent.vue -> 17 | */ 18 | 19 | // const files = require.context('./', true, /\.vue$/i) 20 | // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) 21 | 22 | Vue.component('example-component', require('./components/ExampleComponent.vue').default); 23 | 24 | /** 25 | * Next, we will create a fresh Vue application instance and attach it to 26 | * the page. Then, you may begin adding components to this application 27 | * or customize the JavaScript scaffolding to fit your unique needs. 28 | */ 29 | 30 | const app = new Vue({ 31 | el: '#app', 32 | }); 33 | -------------------------------------------------------------------------------- /resources/views/auth/verify.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Verify Your Email Address') }}
9 | 10 |
11 | @if (session('resent')) 12 | 15 | @endif 16 | 17 | {{ __('Before proceeding, please check your email for a verification link.') }} 18 | {{ __('If you did not receive the email') }}, 19 |
20 | @csrf 21 | . 22 |
23 |
24 |
25 |
26 |
27 |
28 | @endsection 29 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | protected $fillable = [ 23 | 'name', 24 | 'email', 25 | 'password', 26 | 'address', 27 | ]; 28 | 29 | protected $guard = 'isAdmin'; 30 | 31 | /** 32 | * The attributes that should be hidden for serialization. 33 | * 34 | * @var array 35 | */ 36 | protected $hidden = [ 37 | 'password', 38 | 'remember_token', 39 | ]; 40 | 41 | /** 42 | * The attributes that should be cast. 43 | * 44 | * @var array 45 | */ 46 | protected $casts = [ 47 | 'email_verified_at' => 'datetime', 48 | ]; 49 | 50 | public function orders() { 51 | return $this->hasMany(Order::class); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 39 | $this->middleware('signed')->only('verify'); 40 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Policies/FoodPolicy.php: -------------------------------------------------------------------------------- 1 | isAdmin; 33 | } 34 | 35 | /** 36 | * Determine whether the user can update the model. 37 | * 38 | * @param \App\Models\User $user 39 | * @param \App\Models\Post $post 40 | * @return \Illuminate\Auth\Access\Response|bool 41 | */ 42 | public function update(User $user) 43 | { 44 | return $user->isAdmin; 45 | } 46 | 47 | /** 48 | * Determine whether the user can delete the model. 49 | * 50 | * @param \App\Models\User $user 51 | * @param \App\Models\Post $post 52 | * @return \Illuminate\Auth\Access\Response|bool 53 | */ 54 | public function delete(User $user) 55 | { 56 | return $user->isAdmin; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 39 | // $this->middleware('guest:admin')->except('logout'); 40 | } 41 | 42 | // public function showAdminLoginForm() 43 | // { 44 | // return view('auth.login', ['url' => 'admin']); 45 | // } 46 | // public function adminLogin(Request $request) 47 | // { 48 | // $this->validate($request, ['email' => 'required|email', 'password' => 'required|min:6']); 49 | // if (Auth::guard('admin')->attempt(['email' => $request->email,'password' => $request->password], $request->get('remember'))) { 50 | // return redirect()->intended('/admin'); 51 | // } 52 | // return back()->withInput($request->only('email', 'remember')); 53 | // } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | middleware('protected'); 18 | Route::get('/home', [FoodController::class, 'index']); 19 | Route::get('/home/{type}', [FoodController::class, 'filter']); 20 | Route::get('/food/viewfood', [FoodController::class, 'adminIndex'])->middleware('protected'); 21 | Route::view('/food/addfood', 'food.addfood')->middleware('protected'); 22 | Route::post('/food/create', [FoodController::class, 'create']); 23 | Route::get('/food/{food}', [FoodController::class, 'show']); 24 | Route::post('/food/{food}', [FoodController::class, 'update']); 25 | Route::delete('/food/{food}', [FoodController::class, 'destroy']); 26 | Route::post('/food/addfood', [FoodController::class, 'create']); 27 | 28 | 29 | // Order routes 30 | Route::get('order', [OrderController::class, 'show']); 31 | Route::delete('/order/{order_id}', [OrderController::class, 'destroy']); 32 | 33 | // Cart routes 34 | Route::view('cart', 'cart'); 35 | Route::post('/addToCart', [OrderController::class, 'updateCart']); 36 | Route::delete('/cart/remove/{food_id}', [OrderController::class, 'removeFromCart']); 37 | Route::post('/cart/placeorder', [OrderController::class, 'placeOrder']); 38 | 39 | Route::post('/user/edit', [UserController::class, 'update']); 40 | Route::get('/user/edit', [UserController::class, 'updateView']); 41 | Route::delete('/user/{user}', [UserController::class, 'delete']); 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 39 | 40 | $this->routes(function () { 41 | Route::prefix('api') 42 | ->middleware('api') 43 | ->namespace($this->namespace) 44 | ->group(base_path('routes/api.php')); 45 | 46 | Route::middleware('web') 47 | ->namespace($this->namespace) 48 | ->group(base_path('routes/web.php')); 49 | }); 50 | } 51 | 52 | /** 53 | * Configure the rate limiters for the application. 54 | * 55 | * @return void 56 | */ 57 | protected function configureRateLimiting() 58 | { 59 | RateLimiter::for('api', function (Request $request) { 60 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'ably' => [ 45 | 'driver' => 'ably', 46 | 'key' => env('ABLY_KEY'), 47 | ], 48 | 49 | 'redis' => [ 50 | 'driver' => 'redis', 51 | 'connection' => 'default', 52 | ], 53 | 54 | 'log' => [ 55 | 'driver' => 'log', 56 | ], 57 | 58 | 'null' => [ 59 | 'driver' => 'null', 60 | ], 61 | 62 | ], 63 | 64 | ]; 65 | -------------------------------------------------------------------------------- /app/Http/Controllers/UserController.php: -------------------------------------------------------------------------------- 1 | validate([ 19 | 'email' => [ 20 | 'required', 21 | Rule::unique('users')->ignore($id), 22 | ], 23 | 'name' => 'required', 24 | 'address' => 'required', 25 | ]); 26 | 27 | User::where('id', $id)->update([ 28 | 'name' => $user['name'], 29 | 'email' => $user['email'], 30 | 'address' => $user['address'], 31 | ]); 32 | 33 | Session::flash('success', 'Successfully edited the user.'); 34 | return redirect('/home'); 35 | } 36 | 37 | public function updateView() 38 | { 39 | if (!Auth::check()) { 40 | session()->flash('unauthorized', 'You are not authorized to access the page ' . request()->path()); 41 | return redirect('../home'); 42 | } 43 | $user = User::findOrFail(Auth::id()); 44 | return view('editUser', ['user' => $user]); 45 | } 46 | 47 | public function delete($id) 48 | { 49 | $user = User::findOrFail($id); 50 | $user->delete(); 51 | $orders = Order::where('user_id', $id)->get(); 52 | // For each food in the order: 53 | foreach ($orders as $order) { 54 | foreach ($order->food as $food){ 55 | // Remove from pivot table 56 | $order->food()->detach($food->id); 57 | } 58 | $order->delete(); 59 | } 60 | Session::flash('success', 'Successfully deleted your account.'); 61 | return redirect('logout'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Reset Password') }}
9 | 10 |
11 | @if (session('status')) 12 | 15 | @endif 16 | 17 |
18 | @csrf 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | @error('email') 27 | 28 | {{ $message }} 29 | 30 | @enderror 31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | @endsection 48 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": ["framework", "laravel"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^7.3|^8.0", 9 | "doctrine/dbal": "^3.3", 10 | "fruitcake/laravel-cors": "^2.0", 11 | "guzzlehttp/guzzle": "^7.0.1", 12 | "jzonta/faker-restaurant": "^2.0", 13 | "laravel/framework": "^8.75", 14 | "laravel/sanctum": "^2.11", 15 | "laravel/tinker": "^2.5" 16 | }, 17 | "require-dev": { 18 | "facade/ignition": "^2.5", 19 | "fakerphp/faker": "^1.9.1", 20 | "laravel/sail": "^1.0.1", 21 | "laravel/ui": "^3.4", 22 | "mockery/mockery": "^1.4.4", 23 | "nunomaduro/collision": "^5.10", 24 | "phpunit/phpunit": "^9.5.10" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "App\\": "app/", 29 | "Database\\Factories\\": "database/factories/", 30 | "Database\\Seeders\\": "database/seeders/" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "Tests\\": "tests/" 36 | } 37 | }, 38 | "scripts": { 39 | "post-autoload-dump": [ 40 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 41 | "@php artisan package:discover --ansi" 42 | ], 43 | "post-update-cmd": [ 44 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 45 | ], 46 | "post-root-package-install": [ 47 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 48 | ], 49 | "post-create-project-cmd": [ 50 | "@php artisan key:generate --ansi" 51 | ] 52 | }, 53 | "extra": { 54 | "laravel": { 55 | "dont-discover": [] 56 | } 57 | }, 58 | "config": { 59 | "optimize-autoloader": true, 60 | "preferred-install": "dist", 61 | "sort-packages": true 62 | }, 63 | "minimum-stability": "dev", 64 | "prefer-stable": true 65 | } 66 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/confirm.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Confirm Password') }}
9 | 10 |
11 | {{ __('Please confirm your password before continuing.') }} 12 | 13 |
14 | @csrf 15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 | @error('password') 23 | 24 | {{ $message }} 25 | 26 | @enderror 27 |
28 |
29 | 30 |
31 |
32 | 35 | 36 | @if (Route::has('password.request')) 37 | 38 | {{ __('Forgot Your Password?') }} 39 | 40 | @endif 41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | @endsection 50 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 17 | '%s%s', 18 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 19 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' 20 | ))), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Sanctum Guards 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This array contains the authentication guards that will be checked when 28 | | Sanctum is trying to authenticate a request. If none of these guards 29 | | are able to authenticate the request, Sanctum will use the bearer 30 | | token that's present on an incoming request for authentication. 31 | | 32 | */ 33 | 34 | 'guard' => ['web'], 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Expiration Minutes 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This value controls the number of minutes until an issued token will be 42 | | considered expired. If this value is null, personal access tokens do 43 | | not expire. This won't tweak the lifetime of first-party sessions. 44 | | 45 | */ 46 | 47 | 'expiration' => null, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Sanctum Middleware 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When authenticating your first-party SPA with Sanctum you may need to 55 | | customize some of the middleware Sanctum uses while processing the 56 | | request. You may change the middleware listed below as required. 57 | | 58 | */ 59 | 60 | 'middleware' => [ 61 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 62 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 63 | ], 64 | 65 | ]; 66 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been setup for each driver as an example of the required options. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | ], 37 | 38 | 'public' => [ 39 | 'driver' => 'local', 40 | 'root' => storage_path('app/public'), 41 | 'url' => env('APP_URL').'/storage', 42 | 'visibility' => 'public', 43 | ], 44 | 45 | 's3' => [ 46 | 'driver' => 's3', 47 | 'key' => env('AWS_ACCESS_KEY_ID'), 48 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 49 | 'region' => env('AWS_DEFAULT_REGION'), 50 | 'bucket' => env('AWS_BUCKET'), 51 | 'url' => env('AWS_URL'), 52 | 'endpoint' => env('AWS_ENDPOINT'), 53 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 54 | ], 55 | 56 | ], 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Symbolic Links 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Here you may configure the symbolic links that will be created when the 64 | | `storage:link` Artisan command is executed. The array keys should be 65 | | the locations of the links and the values should be their targets. 66 | | 67 | */ 68 | 69 | 'links' => [ 70 | public_path('storage') => storage_path('app/public'), 71 | ], 72 | 73 | ]; 74 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 |
6 |
7 |
8 | {{ __('Login') }} 9 |
10 |
11 |
12 | @csrf 13 |
14 | 15 |
16 | 17 | @error('email') 18 | 19 | {{ $message }} 20 | 21 | @enderror 22 |
23 |
24 |
25 | 26 |
27 | 28 | @error('password') 29 | 30 | {{ $message }} 31 | 32 | @enderror 33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | @endsection -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 39 | } 40 | /** 41 | * Get a validator for an incoming registration request. 42 | * 43 | * @param array $data 44 | * @return \Illuminate\Contracts\Validation\Validator 45 | */ 46 | protected function validator(array $data) 47 | { 48 | return Validator::make($data, [ 49 | 'name' => ['required', 'string', 'max:255'], 50 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 51 | // 'password' => ['required', 'string', 'min:6', 'confirmed'], 52 | 'password' => ['required', 53 | 'min:6', 54 | 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$/', 55 | 'confirmed'], 56 | 'address' => ['required', 'string'], 57 | ]); 58 | } 59 | /** 60 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View 61 | */ 62 | 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => Hash::make($data['password']), 69 | 'address' => $data['address'], 70 | ]); 71 | } 72 | /** 73 | * @param Request $request 74 | * 75 | * @return \Illuminate\Http\RedirectResponse 76 | */ 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /resources/views/components/flash_message.blade.php: -------------------------------------------------------------------------------- 1 | @if ($message = Session::get('success')) 2 |
3 |
4 |
5 | {{ $message }} 6 |
7 |
8 |
9 | 10 |
11 |
12 |
13 | @endif 14 | 15 | 16 | @if ($message = Session::get('error')) 17 |
18 |
19 |
20 | {{ $message }} 21 |
22 |
23 |
24 | 25 |
26 |
27 |
28 | @endif 29 | 30 | 31 | @if ($message = Session::get('warning')) 32 |
33 |
34 |
35 | {{ $message }} 36 |
37 |
38 |
39 | 40 |
41 |
42 |
43 | @endif 44 | 45 | 46 | @if ($message = Session::get('info')) 47 |
48 |
49 |
50 | {{ $message }} 51 |
52 |
53 |
54 | 55 |
56 |
57 |
58 | @endif 59 | 60 | 61 | {{-- @if ($errors->any()) 62 |
63 |
64 |
65 | Please check the form below for errors. 66 |
67 |
68 |
69 | 70 |
71 |
72 |
73 | @endif --}} -------------------------------------------------------------------------------- /resources/views/food/viewfood.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 | 4 |
5 |
6 |
7 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | @foreach($foods as $food) 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 38 | 47 | 48 | 49 | @endforeach 50 |
IDNameDescriptionPriceTypePicture
{{$food['id']}}{{$food['name']}}{{$food['description']}}{{$food['price']}}{{$food['type']}}{{$food['picture']}} 31 | @can('update', $food) 32 |
33 | @csrf 34 | 35 |
36 | @endcan 37 |
39 | @can('delete', $food) 40 |
41 | @csrf 42 | @method('delete') 43 | 44 |
45 | @endcan 46 |
51 | 52 | {{$foods -> links()}} 53 | 54 |
55 |
56 | @endsection -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Fruitcake\Cors\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | ], 41 | 42 | 'api' => [ 43 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 44 | 'throttle:api', 45 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 46 | ], 47 | ]; 48 | 49 | /** 50 | * The application's route middleware. 51 | * 52 | * These middleware may be assigned to groups or used individually. 53 | * 54 | * @var array 55 | */ 56 | protected $routeMiddleware = [ 57 | 'auth' => \App\Http\Middleware\Authenticate::class, 58 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 66 | 'protected' => \App\Http\Middleware\checkAdmin::class, 67 | ]; 68 | } 69 | -------------------------------------------------------------------------------- /resources/views/editUser.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 | @csrf 6 |
7 |
8 |
9 |
10 | 11 |
12 | 13 | @error('name') 14 | 15 | {{ $message }} 16 | 17 | @enderror 18 |
19 | 20 |
21 |
22 | 23 |
24 | 25 |
26 | 27 | @error('email') 28 | 29 | {{ $message }} 30 | 31 | @enderror 32 |
33 |
34 | 35 |
36 | 37 |
38 | 39 | @error('address') 40 | 41 | {{ $message }} 42 | 43 | @enderror 44 |
45 |
46 |
47 |
48 | 49 |
50 |
51 |
52 |
53 | @endsection -------------------------------------------------------------------------------- /resources/views/layouts/auth.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{ config('app.name', 'Online Food Order Management System') }} 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 |
21 | 61 |
62 | @yield('content') 63 |
64 |
65 | 66 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Reset Password') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 | 15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 | @error('email') 23 | 24 | {{ $message }} 25 | 26 | @enderror 27 |
28 |
29 | 30 |
31 | 32 | 33 |
34 | 35 | 36 | @error('password') 37 | 38 | {{ $message }} 39 | 40 | @enderror 41 |
42 |
43 | 44 |
45 | 46 | 47 |
48 | 49 |
50 |
51 | 52 |
53 |
54 | 57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | @endsection 66 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Failed Queue Jobs 79 | |-------------------------------------------------------------------------- 80 | | 81 | | These options configure the behavior of failed queue job logging so you 82 | | can control which database and table are used to store the jobs that 83 | | have failed. You may change them to any database / table you wish. 84 | | 85 | */ 86 | 87 | 'failed' => [ 88 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 89 | 'database' => env('DB_CONNECTION', 'mysql'), 90 | 'table' => 'failed_jobs', 91 | ], 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /resources/views/food/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 |
6 | 7 |
8 |
9 |
10 |

{{ $food['name'] }}

11 |

RM {{ $food['price'] }}

12 |

{{ $food['description'] }}

13 |
14 |
15 |
16 |

Quantity

17 |
18 | 19 |

1

20 | 21 |
22 |
23 | 24 |
25 |
26 |
27 |
28 | 29 | 75 | @endsection -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | ], 56 | 57 | 'memcached' => [ 58 | 'driver' => 'memcached', 59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 60 | 'sasl' => [ 61 | env('MEMCACHED_USERNAME'), 62 | env('MEMCACHED_PASSWORD'), 63 | ], 64 | 'options' => [ 65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 66 | ], 67 | 'servers' => [ 68 | [ 69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 70 | 'port' => env('MEMCACHED_PORT', 11211), 71 | 'weight' => 100, 72 | ], 73 | ], 74 | ], 75 | 76 | 'redis' => [ 77 | 'driver' => 'redis', 78 | 'connection' => 'cache', 79 | 'lock_connection' => 'default', 80 | ], 81 | 82 | 'dynamodb' => [ 83 | 'driver' => 'dynamodb', 84 | 'key' => env('AWS_ACCESS_KEY_ID'), 85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 88 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 89 | ], 90 | 91 | 'octane' => [ 92 | 'driver' => 'octane', 93 | ], 94 | 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Cache Key Prefix 100 | |-------------------------------------------------------------------------- 101 | | 102 | | When utilizing a RAM based store such as APC or Memcached, there might 103 | | be other applications utilizing the same cache. So, we'll specify a 104 | | value to get prefixed to all our keys so we can avoid collisions. 105 | | 106 | */ 107 | 108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /app/Http/Controllers/FoodController.php: -------------------------------------------------------------------------------- 1 | has('asc')) { 18 | if (request()->asc == 'true') { 19 | $foods = Food::orderBy('price')->orderBy('name')->paginate(12); 20 | // orderBy('name') so that for those foods with same price, it will sort alphabetically by their name 21 | } 22 | if (request()->asc == 'false') { 23 | $foods = Food::orderBy('price', 'DESC')->orderBy('name')->paginate(12); 24 | } 25 | } else { 26 | $foods = Food::paginate(12); 27 | } 28 | return view('food.home', ['foods' => $foods]); 29 | } 30 | 31 | public function filter($type) 32 | { 33 | $foods = Food::where('type', '=', $type); 34 | 35 | if (request()->has('asc')) { 36 | if (request()->asc == 'true') { 37 | $sorted = $foods->orderBy('price'); 38 | } 39 | if (request()->asc == 'false') { 40 | $sorted = $foods->orderBy('price', 'DESC'); 41 | } 42 | } else { 43 | $sorted = $foods; 44 | } 45 | return view('food.home', ['foods' => $foods->paginate(12)]); 46 | } 47 | 48 | public function sortByPrice($type) 49 | { 50 | if ($type) { 51 | $foods = Food::orderBy('price')->paginate(12); 52 | } else { 53 | $foods = Food::orderByDesc('price')->paginate(12); 54 | } 55 | 56 | return view('food.home', ['foods' => $foods]); 57 | } 58 | 59 | public function adminIndex() 60 | { 61 | $foods = Food::orderBy('id','desc')->paginate(10); 62 | return view('food.viewfood', ['foods' => $foods]); 63 | } 64 | 65 | public function show($id) 66 | { 67 | $food = Food::findOrFail($id); 68 | return view('food.show', ['food' => $food]); 69 | } 70 | 71 | public function getForUpdate($id) 72 | { 73 | $food = Food::findOrFail($id); 74 | return view('food.updatefood', ['food' => $food]); 75 | } 76 | 77 | public function destroy($id) 78 | { 79 | $food = Food::findOrFail($id); 80 | $food->delete(); 81 | return redirect('/food/viewfood'); 82 | } 83 | 84 | public function create(Request $food) 85 | { 86 | $food->validate([ 87 | 'name' => 'required | unique:food', 88 | 'description' => 'required', 89 | 'price' => 'required', 90 | 'type' => 'required', 91 | 'picture' => 'required' 92 | ]); 93 | Food::create($food->all()); 94 | return redirect('/food/viewfood'); 95 | } 96 | 97 | public function update(Request $food, $id) 98 | { 99 | $food->validate([ 100 | 'name' => [ 101 | 'required', 102 | Rule::unique('food')->ignore($id), 103 | ], 104 | 'description' => 'required', 105 | 'price' => 'required', 106 | 'type' => 'required', 107 | 'picture' => 'required' 108 | ]); 109 | Food::where('id', $id)->update([ 110 | 'name' => $food['name'], 111 | 'description' => $food['description'], 112 | 'price' => $food['price'], 113 | 'type' => $food['type'], 114 | 'picture' => $food['picture'], 115 | ]); 116 | return redirect('/food/viewfood'); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /resources/views/food/home.blade.php: -------------------------------------------------------------------------------- 1 | put('cart', array()); 5 | } 6 | ?> 7 | 8 | @extends('layouts.app') 9 | 10 | @section('content') 11 | 12 | 18 | 19 |
20 |
21 |
22 | Filter By : 23 |
24 | All 25 |
26 |
27 | Western 28 |
29 |
30 | Chinese 31 |
32 |
33 | Japanese 34 |
35 |
36 |
37 | Order By : 38 |
39 | Lowest 40 |
41 |
42 | Highest 43 |
44 |
45 |
46 |
47 | 48 |
49 | @foreach($foods as $data) 50 | 61 | @endforeach 62 |
63 | 64 |
65 | {{$foods -> appends(request()->input()) -> links()}} 66 |
67 | 68 | 94 | @endsection -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Deprecations Log Channel 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This option controls the log channel that should be used to log warnings 28 | | regarding deprecated PHP and library features. This allows you to get 29 | | your application ready for upcoming major versions of dependencies. 30 | | 31 | */ 32 | 33 | 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Log Channels 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may configure the log channels for your application. Out of 41 | | the box, Laravel uses the Monolog PHP logging library. This gives 42 | | you a variety of powerful log handlers / formatters to utilize. 43 | | 44 | | Available Drivers: "single", "daily", "slack", "syslog", 45 | | "errorlog", "monolog", 46 | | "custom", "stack" 47 | | 48 | */ 49 | 50 | 'channels' => [ 51 | 'stack' => [ 52 | 'driver' => 'stack', 53 | 'channels' => ['single'], 54 | 'ignore_exceptions' => false, 55 | ], 56 | 57 | 'single' => [ 58 | 'driver' => 'single', 59 | 'path' => storage_path('logs/laravel.log'), 60 | 'level' => env('LOG_LEVEL', 'debug'), 61 | ], 62 | 63 | 'daily' => [ 64 | 'driver' => 'daily', 65 | 'path' => storage_path('logs/laravel.log'), 66 | 'level' => env('LOG_LEVEL', 'debug'), 67 | 'days' => 14, 68 | ], 69 | 70 | 'slack' => [ 71 | 'driver' => 'slack', 72 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 73 | 'username' => 'Laravel Log', 74 | 'emoji' => ':boom:', 75 | 'level' => env('LOG_LEVEL', 'critical'), 76 | ], 77 | 78 | 'papertrail' => [ 79 | 'driver' => 'monolog', 80 | 'level' => env('LOG_LEVEL', 'debug'), 81 | 'handler' => SyslogUdpHandler::class, 82 | 'handler_with' => [ 83 | 'host' => env('PAPERTRAIL_URL'), 84 | 'port' => env('PAPERTRAIL_PORT'), 85 | ], 86 | ], 87 | 88 | 'stderr' => [ 89 | 'driver' => 'monolog', 90 | 'level' => env('LOG_LEVEL', 'debug'), 91 | 'handler' => StreamHandler::class, 92 | 'formatter' => env('LOG_STDERR_FORMATTER'), 93 | 'with' => [ 94 | 'stream' => 'php://stderr', 95 | ], 96 | ], 97 | 98 | 'syslog' => [ 99 | 'driver' => 'syslog', 100 | 'level' => env('LOG_LEVEL', 'debug'), 101 | ], 102 | 103 | 'errorlog' => [ 104 | 'driver' => 'errorlog', 105 | 'level' => env('LOG_LEVEL', 'debug'), 106 | ], 107 | 108 | 'null' => [ 109 | 'driver' => 'monolog', 110 | 'handler' => NullHandler::class, 111 | ], 112 | 113 | 'emergency' => [ 114 | 'path' => storage_path('logs/laravel.log'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", 32 | | "postmark", "log", "array", "failover" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | 74 | 'failover' => [ 75 | 'transport' => 'failover', 76 | 'mailers' => [ 77 | 'smtp', 78 | 'log', 79 | ], 80 | ], 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Global "From" Address 86 | |-------------------------------------------------------------------------- 87 | | 88 | | You may wish for all e-mails sent by your application to be sent from 89 | | the same address. Here, you may specify a name and address that is 90 | | used globally for all e-mails that are sent by your application. 91 | | 92 | */ 93 | 94 | 'from' => [ 95 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 96 | 'name' => env('MAIL_FROM_NAME', 'Example'), 97 | ], 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Markdown Mail Settings 102 | |-------------------------------------------------------------------------- 103 | | 104 | | If you are using Markdown based email rendering, you may configure your 105 | | theme and component paths here, allowing you to customize the design 106 | | of the emails. Or, you may simply stick with the Laravel defaults! 107 | | 108 | */ 109 | 110 | 'markdown' => [ 111 | 'theme' => 'default', 112 | 113 | 'paths' => [ 114 | resource_path('views/vendor/mail'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /resources/views/food/addfood.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 | @csrf 6 |
7 |
8 |
9 |
10 | 11 |
12 | 13 | @error('name') 14 | 15 | {{ $message }} 16 | 17 | @enderror 18 |
19 | 20 |
21 |
22 | 23 |
24 | 25 |
26 | 27 | @error('description') 28 | 29 | {{ $message }} 30 | 31 | @enderror 32 |
33 |
34 | 35 |
36 | 37 |
38 | 39 | @error('price') 40 | 41 | {{ $message }} 42 | 43 | @enderror 44 |
45 |
46 | 47 |
48 | 49 |
50 | 55 |
56 | 57 |
58 | 59 |
60 | 61 | @error('picture') 62 | 63 | {{ $message }} 64 | 65 | @enderror 66 |
67 |
68 |
69 |
70 | 71 |
72 |
73 | 74 |
75 | @endsection -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 'admin' => [ 44 | 'driver' => 'session', 45 | 'provider' => 'admins', 46 | ], 47 | ], 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | User Providers 52 | |-------------------------------------------------------------------------- 53 | | 54 | | All authentication drivers have a user provider. This defines how the 55 | | users are actually retrieved out of your database or other storage 56 | | mechanisms used by this application to persist your user's data. 57 | | 58 | | If you have multiple user tables or models you may configure multiple 59 | | sources which represent each model / table. These sources may then 60 | | be assigned to any extra authentication guards you have defined. 61 | | 62 | | Supported: "database", "eloquent" 63 | | 64 | */ 65 | 66 | 'providers' => [ 67 | 'users' => [ 68 | 'driver' => 'eloquent', 69 | 'model' => App\Models\User::class, 70 | ], 71 | 72 | // 'users' => [ 73 | // 'driver' => 'database', 74 | // 'table' => 'users', 75 | // ], 76 | 'admins' => [ 77 | 'driver' => 'eloquent', 78 | 'model' => App\Models\Admin::class, 79 | ], 80 | ], 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Resetting Passwords 85 | |-------------------------------------------------------------------------- 86 | | 87 | | You may specify multiple password reset configurations if you have more 88 | | than one user table or model in the application and you want to have 89 | | separate password reset settings based on the specific user types. 90 | | 91 | | The expire time is the number of minutes that each reset token will be 92 | | considered valid. This security feature keeps tokens short-lived so 93 | | they have less time to be guessed. You may change this as needed. 94 | | 95 | */ 96 | 97 | 'passwords' => [ 98 | 'users' => [ 99 | 'provider' => 'users', 100 | 'table' => 'password_resets', 101 | 'expire' => 60, 102 | 'throttle' => 60, 103 | ], 104 | ], 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Password Confirmation Timeout 109 | |-------------------------------------------------------------------------- 110 | | 111 | | Here you may define the amount of seconds before a password confirmation 112 | | times out and the user is prompted to re-enter their password via the 113 | | confirmation screen. By default, the timeout lasts for three hours. 114 | | 115 | */ 116 | 117 | 'password_timeout' => 10800, 118 | 119 | ]; 120 | -------------------------------------------------------------------------------- /resources/views/food/updatefood.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 | @csrf 6 |
7 |
8 |
9 |
10 | 11 |
12 | 13 | @error('name') 14 | 15 | {{ $message }} 16 | 17 | @enderror 18 |
19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 | @error('description') 27 | 28 | {{ $message }} 29 | 30 | @enderror 31 |
32 |
33 | 34 |
35 | 36 |
37 | 38 | @error('price') 39 | 40 | {{ $message }} 41 | 42 | @enderror 43 |
44 |
45 | 46 |
47 | 48 |
49 | 55 |
56 | 57 |
58 | 59 |
60 | 61 | @error('picture') 62 | 63 | {{ $message }} 64 | 65 | @enderror 66 |
67 |
68 |
69 |
70 | 71 |
72 |
73 | 74 |
75 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | @section('content') 3 |
4 |
5 |
6 |
7 |
8 | {{ __('Register') }} 9 |
10 |
11 | 12 |
13 | 14 | @csrf 15 |
16 | 17 |
18 | 19 | @error('name') 20 | 21 | {{ $message }} 22 | 23 | @enderror 24 |
25 |
26 |
27 | 28 |
29 | 30 | @error('email') 31 | 32 | {{ $message }} 33 | 34 | @enderror 35 |
36 |
37 |
38 | 39 |
40 | 41 | @error('address') 42 | 43 | {{ $message }} 44 | 45 | @enderror 46 |
47 |
48 | 49 |
50 | 51 |
52 | 53 | @error('password') 54 | 55 | {{ $message }} 56 | 57 | @enderror 58 |
59 |
60 |
61 | 62 |
63 | 64 |
65 |
66 |
67 |
68 |
69 | 72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | @endsection -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | # Online Food Order Management System 11 | 12 | A web-based food ordering system built on Laravel with MySQL database and CRUD operations. 13 | 14 | ## User Module 15 | ### Home 16 | Home 17 | 18 | ### Food Details 19 | Food Details 20 | 21 | ### Cart 22 | Cart 23 | 24 | ### Order History 25 | Order History 26 | 27 | ## Admin Module 28 | ### View Food 29 | Admin View Food 30 | 31 | ### Add Food 32 | Admin Add Food 33 | 34 | ### Update Food 35 | Admin Update Food 36 | 37 | 38 | 93 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'schema' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | ], 93 | 94 | ], 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Migration Repository Table 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This table keeps track of all the migrations that have already run for 102 | | your application. Using this information, we can determine which of 103 | | the migrations on disk haven't actually been run in the database. 104 | | 105 | */ 106 | 107 | 'migrations' => 'migrations', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Redis Databases 112 | |-------------------------------------------------------------------------- 113 | | 114 | | Redis is an open source, fast, and advanced key-value store that also 115 | | provides a richer body of commands than a typical key-value system 116 | | such as APC or Memcached. Laravel makes it easy to dig right in. 117 | | 118 | */ 119 | 120 | 'redis' => [ 121 | 122 | 'client' => env('REDIS_CLIENT', 'phpredis'), 123 | 124 | 'options' => [ 125 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 127 | ], 128 | 129 | 'default' => [ 130 | 'url' => env('REDIS_URL'), 131 | 'host' => env('REDIS_HOST', '127.0.0.1'), 132 | 'password' => env('REDIS_PASSWORD', null), 133 | 'port' => env('REDIS_PORT', '6379'), 134 | 'database' => env('REDIS_DB', '0'), 135 | ], 136 | 137 | 'cache' => [ 138 | 'url' => env('REDIS_URL'), 139 | 'host' => env('REDIS_HOST', '127.0.0.1'), 140 | 'password' => env('REDIS_PASSWORD', null), 141 | 'port' => env('REDIS_PORT', '6379'), 142 | 'database' => env('REDIS_CACHE_DB', '1'), 143 | ], 144 | 145 | ], 146 | 147 | ]; 148 | -------------------------------------------------------------------------------- /app/Http/Controllers/OrderController.php: -------------------------------------------------------------------------------- 1 | save(); 17 | } 18 | 19 | public function addToOrder(Order $order) 20 | { 21 | } 22 | 23 | public function show() 24 | { 25 | $user_id = Auth::id(); 26 | $orders = Order::where('user_id', $user_id)->orderBy('date', 'desc')->get(); 27 | 28 | // To get total amount for each order: 29 | foreach($orders as $order) { 30 | $total = 0.0; 31 | 32 | foreach($order->food as $food) { 33 | $total += $food->price * $food->pivot->quantity; 34 | } 35 | 36 | $order->total = $total; 37 | } 38 | 39 | return view('order', ['orders' => $orders]); 40 | } 41 | 42 | public function destroy($id) 43 | { 44 | $order = Order::findOrFail($id); 45 | // For each food in the order: 46 | foreach ($order->food as $food){ 47 | // Remove from pivot table 48 | $order->food()->detach($food->id); 49 | } 50 | $order->delete(); 51 | // $order->food()->detach($food_id); 52 | Session::flash('success', 'Successfully deleted order from order history.'); 53 | return redirect('/order'); 54 | } 55 | 56 | public function updateCart(Request $req) 57 | { 58 | if(Auth::check()){ 59 | if(Session::get('cart') == null) { 60 | Session::put('cart', array()); 61 | } 62 | // $food = Food::findOrFail($req['id']); 63 | // $order->food()->attach($food, ['quantity' => $req['quantity']]); 64 | // $order->deliveryAddress = 'aaa'; 65 | 66 | // Check if in the cart session array already has the same food_id in any of its sub-array's 'id' key. 67 | $foodExists = false; // variable for whether that food exists in the cart session array 68 | 69 | // If have, need to add to that quantity, don't push a new array to the cart session array. 70 | if (is_array(Session::get('cart'))) { 71 | $cart_arr = Session::get('cart'); 72 | $cart_id = -1; 73 | foreach ($cart_arr as $subarray) { 74 | $cart_id++; 75 | // Cart session array consists of subarrays. 76 | // Check if array key 'id' is set and whether it is equals to $value that we put into the function 77 | if (isset($subarray['id']) && $subarray['id'] == $req->id) { 78 | // If true, set $foodExists to true. 79 | $foodExists = true; 80 | // Increment the food in the cart session array by the specified quantity. 81 | Session::increment('cart.'.$cart_id.'.quantity', $req->quantity); 82 | Session::save(); 83 | break; // break out of this foreach loop 84 | } 85 | } 86 | 87 | // If don't have, push a new array to the cart session array. 88 | if(!$foodExists) { 89 | $food = [ 90 | 'id' => $req->id, 91 | 'name' => $req->name, 92 | 'price' => $req->price, 93 | 'picture' => $req->picture, 94 | 'quantity' => $req->quantity, 95 | ]; 96 | Session::push('cart', $food); 97 | } 98 | 99 | Session::flash('success', 'Successfully added to cart.'); 100 | } 101 | 102 | return '/home'; 103 | } 104 | else { 105 | Session::flash('info', 'You must be logged in to add to cart and place orders.'); 106 | return '/login'; 107 | } 108 | } 109 | 110 | public function removeFromCart($id) 111 | { 112 | // Function that returns a new cart that doesn't include the food that is to be removed 113 | function getNewCart($array, $key, $value, $cart_id) 114 | { 115 | $cart_arr = array(); 116 | $results = array(); 117 | 118 | // check if it is an array 119 | if (is_array($array)) { 120 | 121 | foreach ($array as $subarray) { 122 | $cart_id++; 123 | // Cart session array consists of subarrays. 124 | // Check if array key 'id' is set and whether it is equals to $value that we put into the function 125 | if (isset($subarray[$key]) && $subarray[$key] == $value) { 126 | // If true, assign this array to array $results 127 | $subarray['cart_id'] = $cart_id; 128 | $results[] = $subarray; // $results contains food that is to be deleted 129 | break; // break out of this foreach loop 130 | } 131 | } 132 | } 133 | 134 | $cart_arr = $array; 135 | array_splice($cart_arr, $cart_id, 1); // remove the item from the cart array 136 | return $cart_arr; 137 | } 138 | 139 | $new_cart_arr = getNewCart(Session::pull('cart'), 'id', $id, -1); 140 | Session::save(); 141 | 142 | // Replace the existing array in the cart session with $new_cart_arr 143 | Session::put('cart', $new_cart_arr); 144 | 145 | Session::flash('success', 'Successfully removed from cart.'); 146 | return redirect('/cart'); 147 | } 148 | 149 | public function placeOrder(Request $req) { 150 | $order = Order::create([ 151 | 'user_id' => Auth::id(), 152 | 'date' => Carbon::now(), 153 | 'type' => $req->type, 154 | 'deliveryAddress' => $req->address, 155 | ]); 156 | 157 | $cart_arr = Session::pull('cart'); // pull: get the value and removes it from the session 158 | foreach ($cart_arr as $key => $value) { 159 | // $key = 0,1,2,...,n $value = 'id','name','price',... 160 | $food = Food::findOrFail($value['id']); 161 | $order->food()->attach($food, ['quantity' => $value['quantity']]); // attach each food in the cart to the newly created order 162 | } 163 | 164 | Session::flash('success', 'Successfully placed order.'); 165 | return redirect('/order'); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION', null), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | While using one of the framework's cache driven session backends you may 96 | | list a cache store that should be used for these sessions. This value 97 | | must match with one of the application's configured cache "stores". 98 | | 99 | | Affects: "apc", "dynamodb", "memcached", "redis" 100 | | 101 | */ 102 | 103 | 'store' => env('SESSION_STORE', null), 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Session Sweeping Lottery 108 | |-------------------------------------------------------------------------- 109 | | 110 | | Some session drivers must manually sweep their storage location to get 111 | | rid of old sessions from storage. Here are the chances that it will 112 | | happen on a given request. By default, the odds are 2 out of 100. 113 | | 114 | */ 115 | 116 | 'lottery' => [2, 100], 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Session Cookie Name 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Here you may change the name of the cookie used to identify a session 124 | | instance by ID. The name specified here will get used every time a 125 | | new session cookie is created by the framework for every driver. 126 | | 127 | */ 128 | 129 | 'cookie' => env( 130 | 'SESSION_COOKIE', 131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 132 | ), 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Session Cookie Path 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The session cookie path determines the path for which the cookie will 140 | | be regarded as available. Typically, this will be the root path of 141 | | your application but you are free to change this when necessary. 142 | | 143 | */ 144 | 145 | 'path' => '/', 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Session Cookie Domain 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Here you may change the domain of the cookie used to identify a session 153 | | in your application. This will determine which domains the cookie is 154 | | available to in your application. A sensible default has been set. 155 | | 156 | */ 157 | 158 | 'domain' => env('SESSION_DOMAIN', null), 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | HTTPS Only Cookies 163 | |-------------------------------------------------------------------------- 164 | | 165 | | By setting this option to true, session cookies will only be sent back 166 | | to the server if the browser has a HTTPS connection. This will keep 167 | | the cookie from being sent to you when it can't be done securely. 168 | | 169 | */ 170 | 171 | 'secure' => env('SESSION_SECURE_COOKIE'), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | HTTP Access Only 176 | |-------------------------------------------------------------------------- 177 | | 178 | | Setting this value to true will prevent JavaScript from accessing the 179 | | value of the cookie and the cookie will only be accessible through 180 | | the HTTP protocol. You are free to modify this option if needed. 181 | | 182 | */ 183 | 184 | 'http_only' => true, 185 | 186 | /* 187 | |-------------------------------------------------------------------------- 188 | | Same-Site Cookies 189 | |-------------------------------------------------------------------------- 190 | | 191 | | This option determines how your cookies behave when cross-site requests 192 | | take place, and can be used to mitigate CSRF attacks. By default, we 193 | | will set this value to "lax" since this is a secure default value. 194 | | 195 | | Supported: "lax", "strict", "none", null 196 | | 197 | */ 198 | 199 | 'same_site' => 'lax', 200 | 201 | ]; 202 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'accepted_if' => 'The :attribute must be accepted when :other is :value.', 18 | 'active_url' => 'The :attribute is not a valid URL.', 19 | 'after' => 'The :attribute must be a date after :date.', 20 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 21 | 'alpha' => 'The :attribute must only contain letters.', 22 | 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', 23 | 'alpha_num' => 'The :attribute must only contain letters and numbers.', 24 | 'array' => 'The :attribute must be an array.', 25 | 'before' => 'The :attribute must be a date before :date.', 26 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 27 | 'between' => [ 28 | 'numeric' => 'The :attribute must be between :min and :max.', 29 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 30 | 'string' => 'The :attribute must be between :min and :max characters.', 31 | 'array' => 'The :attribute must have between :min and :max items.', 32 | ], 33 | 'boolean' => 'The :attribute field must be true or false.', 34 | 'confirmed' => 'The :attribute confirmation does not match.', 35 | 'current_password' => 'The password is incorrect.', 36 | 'date' => 'The :attribute is not a valid date.', 37 | 'date_equals' => 'The :attribute must be a date equal to :date.', 38 | 'date_format' => 'The :attribute does not match the format :format.', 39 | 'declined' => 'The :attribute must be declined.', 40 | 'declined_if' => 'The :attribute must be declined when :other is :value.', 41 | 'different' => 'The :attribute and :other must be different.', 42 | 'digits' => 'The :attribute must be :digits digits.', 43 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 44 | 'dimensions' => 'The :attribute has invalid image dimensions.', 45 | 'distinct' => 'The :attribute field has a duplicate value.', 46 | 'email' => 'The :attribute must be a valid email address.', 47 | 'ends_with' => 'The :attribute must end with one of the following: :values.', 48 | 'enum' => 'The selected :attribute is invalid.', 49 | 'exists' => 'The selected :attribute is invalid.', 50 | 'file' => 'The :attribute must be a file.', 51 | 'filled' => 'The :attribute field must have a value.', 52 | 'gt' => [ 53 | 'numeric' => 'The :attribute must be greater than :value.', 54 | 'file' => 'The :attribute must be greater than :value kilobytes.', 55 | 'string' => 'The :attribute must be greater than :value characters.', 56 | 'array' => 'The :attribute must have more than :value items.', 57 | ], 58 | 'gte' => [ 59 | 'numeric' => 'The :attribute must be greater than or equal to :value.', 60 | 'file' => 'The :attribute must be greater than or equal to :value kilobytes.', 61 | 'string' => 'The :attribute must be greater than or equal to :value characters.', 62 | 'array' => 'The :attribute must have :value items or more.', 63 | ], 64 | 'image' => 'The :attribute must be an image.', 65 | 'in' => 'The selected :attribute is invalid.', 66 | 'in_array' => 'The :attribute field does not exist in :other.', 67 | 'integer' => 'The :attribute must be an integer.', 68 | 'ip' => 'The :attribute must be a valid IP address.', 69 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 70 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 71 | 'json' => 'The :attribute must be a valid JSON string.', 72 | 'lt' => [ 73 | 'numeric' => 'The :attribute must be less than :value.', 74 | 'file' => 'The :attribute must be less than :value kilobytes.', 75 | 'string' => 'The :attribute must be less than :value characters.', 76 | 'array' => 'The :attribute must have less than :value items.', 77 | ], 78 | 'lte' => [ 79 | 'numeric' => 'The :attribute must be less than or equal to :value.', 80 | 'file' => 'The :attribute must be less than or equal to :value kilobytes.', 81 | 'string' => 'The :attribute must be less than or equal to :value characters.', 82 | 'array' => 'The :attribute must not have more than :value items.', 83 | ], 84 | 'mac_address' => 'The :attribute must be a valid MAC address.', 85 | 'max' => [ 86 | 'numeric' => 'The :attribute must not be greater than :max.', 87 | 'file' => 'The :attribute must not be greater than :max kilobytes.', 88 | 'string' => 'The :attribute must not be greater than :max characters.', 89 | 'array' => 'The :attribute must not have more than :max items.', 90 | ], 91 | 'mimes' => 'The :attribute must be a file of type: :values.', 92 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 93 | 'min' => [ 94 | 'numeric' => 'The :attribute must be at least :min.', 95 | 'file' => 'The :attribute must be at least :min kilobytes.', 96 | 'string' => 'The :attribute must be at least :min characters.', 97 | 'array' => 'The :attribute must have at least :min items.', 98 | ], 99 | 'multiple_of' => 'The :attribute must be a multiple of :value.', 100 | 'not_in' => 'The selected :attribute is invalid.', 101 | 'not_regex' => 'The :attribute format is invalid.', 102 | 'numeric' => 'The :attribute must be a number.', 103 | 'password' => 'The password is incorrect.', 104 | 'present' => 'The :attribute field must be present.', 105 | 'prohibited' => 'The :attribute field is prohibited.', 106 | 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', 107 | 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', 108 | 'prohibits' => 'The :attribute field prohibits :other from being present.', 109 | 'regex' => 'The :attribute format is invalid. Password require at least 1 uppercase character(A-Z), 1 lower case character(a-z), 1 digit(0-9), 1 non-alphanumeric value (!, $, #, or %)', 110 | 'required' => 'The :attribute field is required.', 111 | 'required_array_keys' => 'The :attribute field must contain entries for: :values.', 112 | 'required_if' => 'The :attribute field is required when :other is :value.', 113 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 114 | 'required_with' => 'The :attribute field is required when :values is present.', 115 | 'required_with_all' => 'The :attribute field is required when :values are present.', 116 | 'required_without' => 'The :attribute field is required when :values is not present.', 117 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 118 | 'same' => 'The :attribute and :other must match.', 119 | 'size' => [ 120 | 'numeric' => 'The :attribute must be :size.', 121 | 'file' => 'The :attribute must be :size kilobytes.', 122 | 'string' => 'The :attribute must be :size characters.', 123 | 'array' => 'The :attribute must contain :size items.', 124 | ], 125 | 'starts_with' => 'The :attribute must start with one of the following: :values.', 126 | 'string' => 'The :attribute must be a string.', 127 | 'timezone' => 'The :attribute must be a valid timezone.', 128 | 'unique' => 'The :attribute has already been taken.', 129 | 'uploaded' => 'The :attribute failed to upload.', 130 | 'url' => 'The :attribute must be a valid URL.', 131 | 'uuid' => 'The :attribute must be a valid UUID.', 132 | 133 | /* 134 | |-------------------------------------------------------------------------- 135 | | Custom Validation Language Lines 136 | |-------------------------------------------------------------------------- 137 | | 138 | | Here you may specify custom validation messages for attributes using the 139 | | convention "attribute.rule" to name the lines. This makes it quick to 140 | | specify a specific custom language line for a given attribute rule. 141 | | 142 | */ 143 | 144 | 'custom' => [ 145 | 'attribute-name' => [ 146 | 'rule-name' => 'custom-message', 147 | ], 148 | ], 149 | 150 | /* 151 | |-------------------------------------------------------------------------- 152 | | Custom Validation Attributes 153 | |-------------------------------------------------------------------------- 154 | | 155 | | The following language lines are used to swap our attribute placeholder 156 | | with something more reader friendly such as "E-Mail Address" instead 157 | | of "email". This simply helps us make our message more expressive. 158 | | 159 | */ 160 | 161 | 'attributes' => [], 162 | 163 | ]; 164 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => (bool) env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | 'asset_url' => env('ASSET_URL', null), 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Application Timezone 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Here you may specify the default timezone for your application, which 65 | | will be used by the PHP date and date-time functions. We have gone 66 | | ahead and set this to a sensible default for you out of the box. 67 | | 68 | */ 69 | 70 | 'timezone' => 'UTC', 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | Application Locale Configuration 75 | |-------------------------------------------------------------------------- 76 | | 77 | | The application locale determines the default locale that will be used 78 | | by the translation service provider. You are free to set this value 79 | | to any of the locales which will be supported by the application. 80 | | 81 | */ 82 | 83 | 'locale' => 'en', 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Application Fallback Locale 88 | |-------------------------------------------------------------------------- 89 | | 90 | | The fallback locale determines the locale to use when the current one 91 | | is not available. You may change the value to correspond to any of 92 | | the language folders that are provided through your application. 93 | | 94 | */ 95 | 96 | 'fallback_locale' => 'en', 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Faker Locale 101 | |-------------------------------------------------------------------------- 102 | | 103 | | This locale will be used by the Faker PHP library when generating fake 104 | | data for your database seeds. For example, this will be used to get 105 | | localized telephone numbers, street address information and more. 106 | | 107 | */ 108 | 109 | 'faker_locale' => 'en_US', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Encryption Key 114 | |-------------------------------------------------------------------------- 115 | | 116 | | This key is used by the Illuminate encrypter service and should be set 117 | | to a random, 32 character string, otherwise these encrypted strings 118 | | will not be safe. Please do this before deploying an application! 119 | | 120 | */ 121 | 122 | 'key' => env('APP_KEY'), 123 | 124 | 'cipher' => 'AES-256-CBC', 125 | 126 | /* 127 | |-------------------------------------------------------------------------- 128 | | Autoloaded Service Providers 129 | |-------------------------------------------------------------------------- 130 | | 131 | | The service providers listed here will be automatically loaded on the 132 | | request to your application. Feel free to add your own services to 133 | | this array to grant expanded functionality to your applications. 134 | | 135 | */ 136 | 137 | 'providers' => [ 138 | 139 | /* 140 | * Laravel Framework Service Providers... 141 | */ 142 | Illuminate\Auth\AuthServiceProvider::class, 143 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 144 | Illuminate\Bus\BusServiceProvider::class, 145 | Illuminate\Cache\CacheServiceProvider::class, 146 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 147 | Illuminate\Cookie\CookieServiceProvider::class, 148 | Illuminate\Database\DatabaseServiceProvider::class, 149 | Illuminate\Encryption\EncryptionServiceProvider::class, 150 | Illuminate\Filesystem\FilesystemServiceProvider::class, 151 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 152 | Illuminate\Hashing\HashServiceProvider::class, 153 | Illuminate\Mail\MailServiceProvider::class, 154 | Illuminate\Notifications\NotificationServiceProvider::class, 155 | Illuminate\Pagination\PaginationServiceProvider::class, 156 | Illuminate\Pipeline\PipelineServiceProvider::class, 157 | Illuminate\Queue\QueueServiceProvider::class, 158 | Illuminate\Redis\RedisServiceProvider::class, 159 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 160 | Illuminate\Session\SessionServiceProvider::class, 161 | Illuminate\Translation\TranslationServiceProvider::class, 162 | Illuminate\Validation\ValidationServiceProvider::class, 163 | Illuminate\View\ViewServiceProvider::class, 164 | 165 | /* 166 | * Package Service Providers... 167 | */ 168 | 169 | /* 170 | * Application Service Providers... 171 | */ 172 | App\Providers\AppServiceProvider::class, 173 | App\Providers\AuthServiceProvider::class, 174 | // App\Providers\BroadcastServiceProvider::class, 175 | App\Providers\EventServiceProvider::class, 176 | App\Providers\RouteServiceProvider::class, 177 | 178 | ], 179 | 180 | /* 181 | |-------------------------------------------------------------------------- 182 | | Class Aliases 183 | |-------------------------------------------------------------------------- 184 | | 185 | | This array of class aliases will be registered when this application 186 | | is started. However, feel free to register as many as you wish as 187 | | the aliases are "lazy" loaded so they don't hinder performance. 188 | | 189 | */ 190 | 191 | 'aliases' => [ 192 | 193 | 'App' => Illuminate\Support\Facades\App::class, 194 | 'Arr' => Illuminate\Support\Arr::class, 195 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 196 | 'Auth' => Illuminate\Support\Facades\Auth::class, 197 | 'Blade' => Illuminate\Support\Facades\Blade::class, 198 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 199 | 'Bus' => Illuminate\Support\Facades\Bus::class, 200 | 'Cache' => Illuminate\Support\Facades\Cache::class, 201 | 'Config' => Illuminate\Support\Facades\Config::class, 202 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 203 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 204 | 'Date' => Illuminate\Support\Facades\Date::class, 205 | 'DB' => Illuminate\Support\Facades\DB::class, 206 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 207 | 'Event' => Illuminate\Support\Facades\Event::class, 208 | 'File' => Illuminate\Support\Facades\File::class, 209 | 'Gate' => Illuminate\Support\Facades\Gate::class, 210 | 'Hash' => Illuminate\Support\Facades\Hash::class, 211 | 'Http' => Illuminate\Support\Facades\Http::class, 212 | 'Js' => Illuminate\Support\Js::class, 213 | 'Lang' => Illuminate\Support\Facades\Lang::class, 214 | 'Log' => Illuminate\Support\Facades\Log::class, 215 | 'Mail' => Illuminate\Support\Facades\Mail::class, 216 | 'Notification' => Illuminate\Support\Facades\Notification::class, 217 | 'Password' => Illuminate\Support\Facades\Password::class, 218 | 'Queue' => Illuminate\Support\Facades\Queue::class, 219 | 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, 220 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 221 | // 'Redis' => Illuminate\Support\Facades\Redis::class, 222 | 'Request' => Illuminate\Support\Facades\Request::class, 223 | 'Response' => Illuminate\Support\Facades\Response::class, 224 | 'Route' => Illuminate\Support\Facades\Route::class, 225 | 'Schema' => Illuminate\Support\Facades\Schema::class, 226 | 'Session' => Illuminate\Support\Facades\Session::class, 227 | 'Storage' => Illuminate\Support\Facades\Storage::class, 228 | 'Str' => Illuminate\Support\Str::class, 229 | 'URL' => Illuminate\Support\Facades\URL::class, 230 | 'Validator' => Illuminate\Support\Facades\Validator::class, 231 | 'View' => Illuminate\Support\Facades\View::class, 232 | 233 | ], 234 | 235 | ]; 236 | -------------------------------------------------------------------------------- /resources/views/order.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |

5 |
6 | My Order History 7 | 8 | 9 | 10 |
11 |

12 | 13 | {{-- Orders --}} 14 | {{-- Check if user is logged in --}} 15 | @if (auth()->check()) 16 | {{-- Check if user has any orders --}} 17 | @if (count($orders) != 0) 18 | @foreach ($orders as $order) 19 |
20 |
21 |
22 |

Order ID: {{$order->id}}

23 |

Date: {{date_format(date_create($order->date), 'jS F Y')}}

24 |

Type: {{$order->type}}

25 |

Total: RM{{number_format((float)$order->total, 2, '.', '')}}

26 | {{-- flex justify-center leading-normal w-1/6 --}} 27 |
28 | 31 |
32 |
33 |
34 |
35 | @foreach ($order->food as $food) 36 | id}} /> 37 | id}} /> 38 |
39 |
40 | 41 |
42 |
43 |
{{$food->name}}
44 |

Quantity:  {{$food->pivot->quantity}}

45 |

Price:  RM{{number_format((float)($food->price*$food->pivot->quantity), 2, '.', '')}}   [RM{{number_format((float)($food->price), 2, '.', '')}} per unit]

46 |
47 |
48 |
49 | @endforeach 50 |
51 |
52 |
53 |
54 | @endforeach 55 | 56 | 57 | 92 | 93 | 94 | 123 | 124 | 125 | 153 | @else 154 |

155 | Your order history is empty. 156 |

157 | @endif 158 | @else 159 |

160 | You must be logged in to view your order history. 161 |

162 | @endif 163 | 164 | {{-- Just for some spacing before the end of page (footer) --}} 165 |
166 | 167 | 195 | @endsection --------------------------------------------------------------------------------