Skip to content

Audubon Project Commit #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: matt-training
Choose a base branch
from
Open

Audubon Project Commit #2

wants to merge 1 commit into from

Conversation

mjvladika
Copy link

Audubon Project:
Bird, Member, Capture Entities and Database Tables
BirdController Controller
Migration File For Creating Database and Tables
Form View, Thanks for the Submission View, All Sightings View
Save service class
Created unit tests for service class

Screenshot 2023-08-04 at 11 20 37 AM
Screenshot 2023-08-04 at 11 21 30 AM
Screenshot 2023-08-04 at 11 22 49 AM
Screenshot 2023-08-04 at 11 23 11 AM
Screenshot 2023-08-04 at 11 24 38 AM


class BirdController extends Controller
{
public function audubonSociety(): view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function names should be more descriptive of what they do. In this case you're adding a sighting, so sighting or addSighting would be a better function name.


public function saveAudubonSociety(Request $request, saveService $saveService): view
{
//var_dump($request->input());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var_dump that you forgot to remove.

return view('redirect-after-submit');
}

public function displayAllSightings(): view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is fine, but often for displaying multiple lists we often will use index as the function name that shows multiple entries of something. Not every time, but usually. I probably wouldn't call this out, but it's worth noting.

private $id;
private $date_time;
private $location;
private $member_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, do not use _. So it should be $memberID. $date_time could be $date or something more descriptive if you want. Generally $date is pretty obvious what it is for. Like in this case it's safe to assume that date is the date of the capture, so I don't think it's necessary to be any more descriptive than $date.


public function putDataIntoClasses($data): void
{
$this->birdObj = $this->getBirdData($data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you have a few bird related variables, I think obj is unnecessary. There may be some cases where you access it many times on various functions where it makes sense to make it a global variable. In this case, you'd only have to pass it to one function, so I'd just make it a local variable. $bird, $member, $capture. That is the syntax for creating a local variable.

{
Schema::create('Member', function($table){
$table->increments('id')->unsigned();
$table->string('name', 50)->nullable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're starting to use char now. string creates varchar.

Schema::create('Bird', function($table){
$table->increments('id')->unsigned();
$table->string('species', 50);
$table->string('description', 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description is very likely to have cases where it's pretty long. It should be a text. Also, you used a text input on the form, but it should be textarea to give more room to type.

<head>
<title>Audubon Society Capture Form</title>
</head>
<body style='text-align: center; border-width:5px; border-style:solid; color:black; width:fit-content'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to add styles in this test project, but very rarely should we add inline styles. style="display: none" is commonly used if we want to hide by default. That inline style is fine, but others shouldn't be used for the most part.

use Audubon\Entities\Member;
use PHPUnit\Framework\TestCase;

final class saveServiceTest extends TestCase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classes should always start with caps. So it should be SaveService and SaveServiceTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants