diff --git a/application/controllers/dummy.php b/application/controllers/dummy.php new file mode 100644 index 0000000..924ef9d --- /dev/null +++ b/application/controllers/dummy.php @@ -0,0 +1,47 @@ +model = $model; + } + + public function index(): void + { + $data = $this->model->getData(); + $this->render('views/example_view.php', ['data' => $data]); + } + + public function show(int $id): void + { + $item = $this->model->find($id); + + if ($item === null) { + $this->notFound(); + return; + } + + $this->render('views/item_view.php', ['item' => $item]); + } + + private function render(string $viewPath, array $data): void + { + extract($data); + include $viewPath; + } + + private function notFound(): void + { + http_response_code(404); + include 'views/404.php'; + } +} diff --git a/assets/js/dummy.js b/assets/js/dummy.js index f12c104..f8fb829 100644 --- a/assets/js/dummy.js +++ b/assets/js/dummy.js @@ -1,50 +1,44 @@ -// src/index.js +// Importing React (necessary if using JSX) +import React from "react"; -// Example function to add two numbers -function add(a, b) { - return a + b +// Example function using a regular function declaration +function multiply(x, y) { + return x * y; } -// Example usage of the add function - -const result = add(5, 10) -console.log('The result is:', result) - -// Example object with properties -const person = { - name: 'John Doe', - age: 30, - greet: function () { - console.log( - `Hello, my name is ${this.name} and I am ${this.age} years old.` - ) - }, -} - -// Call the greet method -person.greet() - -// Example of an arrow function -const multiply = (x, y) => x * y - -console.log('The product is:', multiply(4, 5)) +// Example usage of a function +let result = multiply(4, 5); +console.log("The product is:", result); // Output: The product is: 20 // Example of a variable declared with let -let count = 0 +let count = 0; for (let i = 0; i < 5; i++) { - count += i -} -console.log('The count is:', count) - -// Example of a variable declared with const -const message = 'This is a constant message.' -console.log(message) - -// Example of a function with default parameters -function greet(name = 'Guest') { - console.log(`Welcome, ${name}!`) + count += i; } -// Call the function with and without arguments -greet('Alice') -greet() +console.log("The count is:", count); // Output: The count is: 10 + +// Example of a variable declared with let (instead of const) +let message = "This is a message"; +console.log(message); + +// Example of a React functional component +function Greeting({ name }) { + return ( +