Aww CRUD, here we go again

Overview

Aww CRUD, here we go again

This is a team assignment which will teach us how to connect to a database, write a simple Create, Read, Update and Delete application and how to use a provided MVC structure to work into.

Learning all that stuff, combined with working in group and improving our git behaviour, will make this assignment a spicy one.

In order to start out with the assignment, we will clear the following TO-DO list:

  • Create a basic Database
    • Table for Students
    • Table for Classes (groups)
    • Table for Coaches
  • Create a router that selects different pages
  • Create a .gitignore that ignores the .env, .gitignore, and if needed, the .idea/
  • Add a .env.sample file to the repository
  • Show our database on the view
    • Create a connection with the database
    • Create a new Database in index
    • Create a property 'Database' in the controller
      • Just a generic Database, not specific information per controller.
    • Be able to do a 'getAllCoaches' in the view, or wherever you'd like as long as it works.
      • Learn a bit more about PDO and how to utilize it.

Once we're done with that TODO list, we can once again have a group meeting to further decide on small future goals and how to achieve them. The very first big goal we have, is to be able to show our database on the view. Once that's done and we're 1000% sure everything's connected, we can go ahead and get CRUD done.

Putting the C-U-D in CRUD

We were finally able to have visitors to the site READ our database, the R in CRUD is now done. This means that our database has been successfully connected to our MVC. Now that we're able to connect to the database, we can start thinking of more concrete, visual goals we would like to achieve.

  • Display the Database Table to the corresponding page
    • Discuss and decide on what kind of layout we want Once that display has been completely done by all the members in our team, we can start working on the must-have features of this assignment.

Plan of Attack!!

Now that the database connection has been made, we will form our plan of attack! We will start out by creating a production branch In this branch, we will add a branch for every thing on the To-Do list. The tasks will be also split evenly among us. Besart will be responsible for the Teachers, Greet for the Students, and Jelle for the Groups.

An example of this method of working is, if I want to add a new delete button to the Teacher table, I will create a branch called deleteButtonTeacher, finish this in this branch, and merge that branch into production. Since this is the way the pro's do it, this will also be the way we will teach it ourselves.

Next, we will need to add the following:

  • A delete button in the Student page
  • An add button in the Teacher Page
  • Get a connection on the Group Page
  • An Edit button in the Group page

Must-have features

You have to provide the following pages for Students, Teacher & Class.

  • A general overview of all records of that entity in a table
    • Each row should have a button to edit or delete the entity
    • This page should have a "create new" button
  • A detailed overview of the selected entity
    • This should include a button to delete this entity
    • Edge case: A teacher cannot be removed if he is still assigned to a class
    • Edge case: If you remove a class, make sure to remove the link between the students and the class.
  • A page to edit an existing entity
  • A page to create a new entity

One way to make the button work, is by giving them a specific value to what they need to do and need to be.

Choose your favorite subject: -> Add queries in different functions -> In the Render, add if functions to call on different functions -> if ($_GET = "delete") { call the function to delete the entire row by the value that was given by the user} ->Now we need to figure out how to update information in a table, what do we need to add for the user to let them change a single value in the table">
Choose your favorite subject: -> Add queries in different functions -> In the Render, add if functions to call on different functions -> if ($_GET = "delete") { call the function to delete the entire row by the value that was given by the user} ->Now we need to figure out how to update information in a table, what do we need to add for the user to let them change a single value in the table

Fields:

On the general overview table you can yourself decide what would be useful information to show.

On the detailed overview you have to provide the following information:

Student

  • Name
  • Email
  • Class (with clickable link)
  • Assigned teacher (clickable link - relation via class)

Teacher

  • Name
  • Email
  • List of all students currently assigned to him (clickable link)

Class

  • Name class (Giertz, Lamarr, ...)
  • Location (Antwerp, Gent, Genk, Brussels, Liege)
  • Assigned teacher (clickable link)
    • Assigned Teacher shows
    • Clickable link
  • List of assigned students (clickable link)

Creating the Connection to the Database

Just like the previous assignment, this exercise was a toughie. But thanks to this exercise, I have gotten a better understanding of how connecting to the database works.

Install Composer (check if installed by writing 'composer -v' in command line) In command prompt, go to folder of this exercise, and run 'composer install' In datagrip, run MySql as script -> Creates Database for you Check if database connection works by opening localhost and going to 'Teachers'.

problems we encountered

  1. Getting data from the database depends on the program you use. MariaDB needs a different syntax than Mysql.

string:

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

should be replaced with:

ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

This is a story all about how

Our CRUD and MVC were flipped-turned upside down

And I'd like to take a minute

Just sit right there

I'll tell you how we became the royalty of a town called BeCode

alt-text

How we got started

We started out by splitting up different tasks:

  • Besart made the Database
  • Jelle made the index and boilerplate MVC
  • Greet was responsible for the Composer and researching how to set up a connection

Once these steps were done, we collectively worked on getting a connection from the database to the view. We also assigned Besart to be the designated README enthusiast, while also setting up our gitignores so no unecessary files were added to the repository.

To-Do #1

When everything we had to do collectively was done, we created a new to-do list. Our goal was to show a table per subject. Besart had to show the table of the Teachers, Greet of the Students, and Jelle for the Classes.

Our goal to work this way, was for everyone to work with the MVC, and not have a single person be responsible for the Model, one for the View and one for the Controller. Every single on our goals and To-Do's was made with wanting to learn and improve in mind. But just because the tasks were split up, doesn't mean we all worked separate from one another. When someone had some troubles, we used the power of teamwork to help each other out. This way, the person who had issues gets to learn how to fix them, while those helping also learn from the experience.

GitHub

Up until this point, we were all working on the main branch. But from here on out, we decided to create a new branch called 'production', and create separate branches for every functionality we wanted to add. Once someone was done with their separate branch, they merged it into production. Afterwards, they once again created a new branch for that specific function.

We wanted to work this way, because Greet (and Koen) told us this is how it's done in a professional environment. And the best way to learn is to jump head-first into new challenges!

To-Do #2: Electric Boogaloo

Once all tables were shown on the site, we once again made a new To-Do list.

  • Besart was responsible for the 'Create New' function
  • Jelle was responsible for the 'Edit Entity' function
  • Greet was responsible for the 'Delete' function

The Story of Besart: Creating a new Entity

I was responsible for adding the 'Create New' function. After creating a ton of headaches for myself, I was finally able to create a new teacher.

The MVC structure was already done by this point, so I only had to add a field in the view for user input and the function that adds a new teacher. I started out by writing down my query in datagrip to achieve the desired result. Once I had the query, I wrote the function and added the query I wrote earlier, replacing some values for some variables.

This is where I struggled the most. Why use many word when few code do trick:

$this->databaseLoader->getConnection()->query("INSERT INTO teacher_table VALUES ( id ,' . " . ' .$name. ' . " . ', ' . " . ' .$email. ' . " . ')");
$this->databaseLoader->getConnection()->query("INSERT INTO teacher_table VALUES ( id ,'$name', '$email')");

What I am most proud of, is the things I learned during this assignment. We were able to make a database that is fully CRUD-dable (no idea if that's an actual word but Josh Darnit does that 'word' do the job).

Story of Jelle: Edit Entities

What I did:

  • made the boilerplate maps, created the header & footer includes
  • made the controller, views & model for the groups
  • focussed specificly on the 'edit' functionality
  • included all the other functionality by looking at teammembers code

How I did it:

  • check the code 😉

What I struggled with

  • running the local database, decided to download DataGrip so my teammembers could help out
  • ran into some weird PDO errors but with the help of the coaches I managed to solve them

What I'm proud of:

  • we made the whole crud thing work despite the time restraints

The Story of Greet: Deleting Entities

I started with reading some info about CRUD.

  • my task was creating the delete function
  • The function itself was easy to find, but I struggled some time looking up what should go where. (controller, model, view) and how it was all connected. Luckily Jelle and Besart were able to help me on my way
  • in the end it worked

What we learned

  • How to effectively use Github
  • Communication
  • Helping each other is a valuable way to learn things yourself
  • MVC is not easy at all, but we're getting there!
  • Repetition is key! Because this is the second exercise we did with MVC and databases, this one went a lot more smoothly.

What we wanted to learn

  • PDO::prepare (how to safely get user input and put it in the database)
  • Link with detailed table
  • Linking teacher name to student
  • Understanding keys in the database on a deeper level
  • Subqueries
  • Look through each other's code collectively, and improve our own code where necessary

What we're proud of

  • TEAM SPIRIT!!!!!
  • Not done on time, but we all worked on this assignment in the weekend
  • Communication and responsibility
  • -> Scroll back to what we learned
  • Prioritising work (for example, ignoring styling in favor of functionality)
You might also like...
mongo php crud

mongodb-crud for php you can use this package as your php project standalone or include necessary class and files into your project how to use. simply

Berikut Adalah cara untuk melakukan CRUD di FrameWork Laravel, Silahkan Disimak

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

CRUD PHP developed by Fabio Augusto.

CRUD system with PHP 7.4, PDO and JWT authentication Important Open-source software system developed and maintained by: Fabio Augusto Full PHP develop

How to Create Laravel 8 Vue JS CRUD Example

About Project How to Create Laravel 8 Vue JS CRUD, how to implement vue js crud example with Laravel 8. how to Create a crude API in Laravel 8, for ex

Crud en Laravel 8 con dos tablas relacionadas

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

A simple Symfony 5 CRUD

A basic Symfony 5 CRUD application

Minicursos de CRUD com o Laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Create Migration, Seed, Request, Controller, Model and Views for your resource (CRUD)

Table of Contents Laravel Resourceful NOTE! Usage Install through composer Add Service Provider Run it! Example Generated Controller Generated Views I

Dockerized Laravel project with authentication and car brand crud functionalities.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Owner
null
Here you have yet another framework for writing RESTful web services in PHP

PHP-Rocker Here you have yet another framework for writing RESTful web services in PHP, jay! What sets this framework apart from many of the others is

Victor Jonsson 43 May 19, 2022
LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like Advanced CRUD Generation, Module Manager, Backups and many more.

LaraAdmin 1.0 LaraAdmin is a Open source CRM for quick-start Admin based applications with features like Advanced CRUD Generation, Schema Manager and

Dwij IT Solutions 1.5k Dec 29, 2022
Until 2018, Backpack v3 used this Base package to offer admin authentication and a blank admin panel using AdminLTE. Backpack v4 no longer uses this package, they're now built-in - use Backpack/CRUD instead.

Note: This package is only used by Backpack v3. Starting with Backpack v4, everything this package does is included in Backpack/CRUD - one package to

Backpack for Laravel 845 Nov 29, 2022
:elephant: A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.

Laravel Vue Boilerplate A Laravel 6 Single Page Application boilerplate using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass and Pug with: A users

Alefe Souza 533 Jan 3, 2023
Laravel and Vue js CRUD

Laravel and Vue js PhoneBook app In this project I have done a simple CRUD using Laravel and Vue Js. Here I have used : Vue router Sweetalert2 Resourc

AR Shahin 4 Jun 11, 2022
Basic Crud Generator (With Code Files, like GII (YII2)) Using Laravel, Livewire and Tailwind CSS

LiveCrud Live Crud Generator. This package generates Basic Crud with Livewire. Features Generate Complete Crud With Livewire Component and Blade Files

Ritesh Singh 28 Oct 12, 2022
This package provides an artisan command to generate a basic crud with Restful API support

NHRROB Crud Generator Package This package provides an artisan command to generate a basic crud composer install command: composer require nhrrob/crud

Nazmul Hasan Robin 22 Jun 24, 2022
Laravel Package for crud generation

Crud and API Generator Package Package which let's you automate tedious CRUD Operations. Requirements Laravel Version: >= 8.0 PHP Version: >= 7.3 Comp

Niraj Basnyat(badass) 12 Mar 29, 2022
A Laravel admin panel which is creating CRUD for your application automatically.

Adds a zero configuration Admin Panel to your Laravel Application Installation You can install the package via composer: composer require max-hutschen

42coders 10 Aug 24, 2022
A simple CRUD built in PHP, Bootstrap and MySQL

✨ Notes-CRUD ✨ A simple CRUD built in PHP, Bootstrap and MySQL ?? Table of Contents Usage Contribute Screenshots ?? Usage Add the project to your envi

Bonnie Fave 7 Dec 7, 2022