Giter VIP home page Giter VIP logo

e15-spring23's People

Contributors

susanbuck avatar

Watchers

 avatar  avatar

e15-spring23's Issues

Prevention of escaped characters

By default, Blade's echo syntax escapes special characters to prevent XSS attacks. One way to prevent this behavior is to enclose a variable containing special characters with the syntax {!! !!}. On my bookmark site, I created the following variable:

$ampersand = '&'

I then added the following HTML code to the Bookmark welcome page:

<body>
    <h1>Bookmark</h1>

    <p>Here is the ampersand variable escaped: {{ $ampersand }}</p>

    <p>And here it is not escaped: {!! $ampersand !!}</p>
</body>

Here are the results:
image

Alternately, you can add the line Blade::withoutDoubleEncoding to the boot method of the AppserviceProvider. This would disable escaping throughout the entire Laravel app:

<?php
 
namespace App\Providers;
 
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
 
class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Blade::withoutDoubleEncoding();
    }
}

One reason you may want to do this is to display how escaping works, as can be seen in the Performed translations table on the htmlspecialchars page in the PHP manual: htmlspecialchars

P3 wont install Fortify

root@hes:/var/www/e15/p3# composer update 
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? y
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/framework v10.0.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.0.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.0.3 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.3 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.4 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.1.5 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.2.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.3.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.3.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.3.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.3.3 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.4.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.4.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.5.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.5.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.6.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.6.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.6.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.7.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.7.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.8.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v10.9.0 (conflict analysis result)
    - spatie/laravel-ignition[1.5.0, ..., 1.6.4] require illuminate/support ^8.77|^9.27 -> satisfiable by illuminate/support[v8.77.0, ..., v8.83.27, v9.27.0, ..., v9.52.7].
    - spatie/laravel-ignition[1.0.0, ..., 1.4.1] require illuminate/support ^8.77|^9.0 -> satisfiable by illuminate/support[v8.77.0, ..., v8.83.27, v9.0.0, ..., v9.52.7].
    - Only one of these can be installed: illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.7, v10.0.0, ..., v10.9.0], laravel/framework[v10.0.0, ..., v10.9.0]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
    - Root composer.json requires laravel/framework ^10 -> satisfiable by laravel/framework[v10.0.0, ..., v10.9.0].
    - Root composer.json requires spatie/laravel-ignition ^1.0 -> satisfiable by spatie/laravel-ignition[1.0.0, ..., 1.6.4].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Project planning tips?

Hi everyone! A lot of you have more experience in this field than I and so I'm hoping you can give me some advice on how you approach projects.

What are some tools, applications, strategies you use when designing a project? How, when you're in the design stage, do you keep track of the different things you want your app to be able to do, the views you want it to have, how you want it to all be laid out?

I'm not a great planner and tend to jump in and things end up less organized than I'd like--or I spend a lot of time trying to go back and put some sort of order to the original disorder I've created!!

Thanks!
-Anne

Routing Error for deleting books from user list

I'm working on the practice feature in the Bookmark application to delete a book from a user list, and am running into what I assume is a routing error, but am not sure. When I attempt to click on the delete link in the list, I receive an error that says "The GET method is not supported for route list/removeBook. Supported methods: DELETE."

I've researched the issue and the general concensus seems to be that this error happens when a person forgets to include {{ method_field('delete') }} in their form. However, I do have this in my form. Here are the different relevant pieces of my code:

Route::get('/list/{slug}/delete', [ListController::class, 'delete']);
Route::delete('/list/{slug}', [ListController::class, 'destroy']);

The href for the remove from list button:

<a href='/list/{{ $book->slug }}/delete'><i class='fa fa-minus-circle'></i> Remove from your list</a>

My form in the removeBook blade (the purpose of the blade is to verify that a user wants to delete the book from their list):

    <form method='POST' action='/list/{{ $book->slug }}'>
        {{ method_field('delete') }}
        {{ csrf_field() }}
        <button type='submit' class='btn btn-danger'>Delete {{ $book->title }}</button>
    </form>

And my ListController Functions:

public function delete($slug)
    {
        $book = Book::findBySlug($slug);

        if (!$book) {
            return redirect('/list')->with([
                'flash-alert' => 'Book not found'
            ]);
        }

        return view('/list/removeBook', ['book' => $book]);
    }

    public function destroy($slug)
    {
        $user = $request->user();
        $book = Book::findBySlug($slug);

        $book->users()->detach();

        $book->delete();

        return redirect('/list')->with([
            'flash-alert' => '“' . $book->title . '” was removed from your list.'
        ]);
    }

I think I've been staring at the problem for so long that I can't see the error. If anyone has run into this before, or can spot the error, I would really appreciate the insight.

End of Semester FAQ

FAQ: Will I have access to course notes/examples after the semester is over?
An archive of notes/code will be made available and emailed to you sometime before the Fall 2023 semester starts. Lecture videos will be available for 3 months.

FAQ: When will I know my final grade for this course?
HES will make final grades available via Online Services on Tuesday, May 23. By or before then, I will have completed feedback/grading for your Project 3, which you’ll be able to see in Canvas as usual.

non-coding question - staying connected

Hi all, not coding related,
Wondering if anyone is going to the virtual career fair tomorrow or taking school on-campus this summer.

Here's my email to stay in contact [email protected] and/or we can connect via linkedin . FYI I'm a ALM student on class 5/12 and a coder by day. Would like to stay in contact with fellow students I meet along the way.

Susan, please delete if this is not appropriate for this forum.

Thanks,
Brad

Undefined type 'Laravel\Fortify\Fortify'

I installed Fortify in my p3 project, and create a service provider for it, but I'm getting the error Undefined type 'Laravel\Fortify\Fortify'. Please see the attached screenshot for more detail.
fortify

Week 6 - User Authentication

Something that stuck out to me while going through this weeks readings was the block on authentication. When building an application, giving your user the ability to register, login and logout is extremely important to having a tailored and secure website experience, so I decided to read more about it.

Our reading had a section on authentication directives, which showed that you can very easily check if the current user is authenticated or not, and display custom data, by using @auth/@endauth or @guest/@endguest tags.

I tested this in our bookmark application with the following code:

@auth

<p>You are currently an authenticated user.</p>

@endauth

@guest

<p>You are not logged in. Please login <a  href='/'>here</a>.</p>

@endguest

Although this is a very simplistic test, it does show what we would expect for an unauthorized user. However, I can’t yet test if the auth tag works as expected because there is nothing set in place to allow a user to register and login in on this application.

I decided to read a little further on how we might allow user registration in the future and came across one of the starter kits that Laravel provides, called Breeze. Breeze integrates with your Laravel application to help you with allowing a user to authenticate him/herself by providing you with routes, controllers and views that you would need to register, login and logout your users.

You can read more about Laravel Breeze here.

And you can view my very simple test of an unauthenticated user here.

Codeception bootstrap errors, didn't install acceptance

ot@hes:/var/www/e15/p3/tests/codeception# codecept generate:cest acceptance LoginPage

In Configuration.php line 341:

Suite acceptance was not loaded

generate:cest

root@hes:/var/www/e15/p3/tests/codeception# cd ../..
root@hes:/var/www/e15/p3# codecept bootstrap tests/codeception

==== Redirecting to Composer-installed version in vendor/codeception. You can skip this using --no-redirect ====

In InitTemplate.php line 201:

Codeception is already installed in this directory

bootstrap [-s|--namespace [NAMESPACE]] [-a|--actor [ACTOR]] [-e|--empty] [--] []

root@hes:/var/www/e15/p3#

Alert Message: Found 1 security vulnerability advisory affecting 1 package

When I ran the command
composer require "codeception/module-asserts" --dev

I got a message saying: "Found 1 security vulnerability advisory affecting 1 package" and suggesting I "run composer audit for a full list of advisories."

When I did that, I got an alert about the package: guzzlehttp/psr7. Is there anything I should do about this?

Thanks!

Unable to create new controller

I attempted to make a new controller, because I felt my RoutesController was becoming cluttered. However, when I entered php artisan make:controller ListController I recieved an error saying "local.ERROR: Unable to detect application namespace". After researching the issue, it was suggested to do a composer diagnose. This doesn't reveal any issues. Everything seems to be ok. It also suggested running a composer update, but this lead to more issues. I'm now receiving the following error:

"Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255"

And now my project won't even load on my server. Has anyone else run into this issue?

Assignment post - template inheritance

This weeks assignment requires a post here regarding routes and views and readings. I followed the material and created a template, used the template, created a view, and added a call to the view in the controller.

http://bookmark.davidcurtis.me/books/title
template:
<!doctype html>

<title>@yield('title')</title> @yield('head');
<section>
    @yield('content');
</section>

<footer>
    &copy; My E15 bookmark footer
</footer>

View:

@extends('layouts/main')

@section('title')
{{ 'Hello Im the title' }}
@endsection

@section('head')
{{ 'Im the head section' }}
@endsection

@section('content')
{{ 'im the content' }}
@endsection

FYI Course archive email sent

I just sent an email to everyone with details on how to download an archive of course material. If for some reason you did not get this email, let me know.

P2 success results?

I think I have P2 mostly done, I'm going to a success page that validates and dumps the request variables to the page on success.

I'm not attempting to reload the page with form data on a refresh click or anything like that.

On validation failure I'm returning to the form and populating with the old data.

Just looking to confirm that this meets the goals for P2.

Using p2 as a base for p3?

I'm planning to start p3 from where I left of with p2. I started by doing a copy and past in VSCode of the p2 directory into a p3 directory. I know I will need to setup the web server to recognize p3 and a few other things but I'm wondering if this is an 'ok' thing to do in the laravel environment or if laravel needs to actually create the project due to underlying configurations or something like that... also thought this would make an interesting post for the class collaborations.

Thanks.

Palindrome question

For assignment 1, the instructions says that the palindrome processor should ignore special characters. But how should the processor handle strings that consist of only special characters?

Caused issues by installing certbot to run SSL on p3

I installed certbot and was running ssl on p3 and due to the auth errors tried to remove the ssl from the nginx configuration manually and some other things. Running into a downward spiral over the composer update failure. Appears to me to be a compatibility issue between the new release of Laravel and the composer update for fortify. The only thing still working for me is my bookmark app and it wont authenticate because of the composer dependency being removed.

Issues connecting to the server

Hello,

I am working through video 3 - Remote Development, and am encountering issues connecting to the servier. I have followed the steps outlined in the video to install/setup the remote development extension and configuring my connection. When I attempt to connect, a new VSCode window appears and attempts to connect to the host, but ultimatley is not able to.

I've included several screenshots of the windows I encounter. The first is showing my config file with the host name updated to my IP address. I've saved the file several times to make sure that isn't the issue. The second screenshot is simply showing the new window that initially pops up when I attempt to connect to the host. The third screenshot is the error messages that occur when choosing windows as the platform of the remote host. I'm not sure if it's necessary to choose a platform, but when I do, this is when I finally get a response from the window that the attempt to connect has failed. I've retraced my steps, but am encountering the same result each time.

I'm not sure why the connection is failing. If anyone has ideas, I would really appreciate it!

Screenshot of terminal and config file

Opening remote stuck

retry loading window

P2 Problem Rendering Results and Default Check Box

Hi,

My project is almost done.

I just need help with 2 main things:

  1. I can't figure out the Default Check Box and I'm running into this error
    with this ternary operator:
    {{ ($price == '') ? 'checked' : 'Enter value' }}

i.e.: If $price has any input then 'check' the box. If not, uncheck.

https://flareapp.io/share/67OgOwv7#F54

Screenshot 2023-03-21 at 21 17 14

  1. I'm encountering this bug when I render my results in an input box

https://flareapp.io/share/B5ZN2Wv5#F54

@if(!is_null($net_total))

       <div class='results alert alert-warning'>
           Please enter appropriate values.
       </div>
   @else
       <div class='results alert alert-primary'>
           <div>
               <label for='net_total'>Net Total</label>
               <input type='number' name='net_total' id='net_total' value='{{ $net_total }}'>
           </div>
       </div>
   @endif
  

Project 2 Peer Review thread

In this week’s upcoming assignment (Week 9, Mar 28), I'll prompt you to complete a peer review of a classmate’s Project 2. You will share your completed review in a reply to this thread.

Full instructions of the peer review process are in the Week 9 assignment.

Peer review spreadsheet...

VSCode Snippets

In this week's videos, you'll see me make reference to a feature in VSCode called snippets where you can define shortcuts for frequently used code blocks. Specifically, I'll use snippets to fill out the basic HTML structure of a view file.

If you've never worked with snippets before, here's some general info: https://code.visualstudio.com/docs/editor/userdefinedsnippets

Also, here is a video tutorial I have on working with snippets...

Below is the HTML snippet you saw me use in this week's videos:

{
	"HTML Template": {
		"prefix": "html",
		"body": [
			"<!doctype html>",
			"<html lang='en'>",
			"<head>",
			"    <title></title>",
			"    <meta charset='utf-8'>",
			"    <link href=data: , rel=icon>",
			"</head>",
			"<body>",
			"$0",
			"</body>",
			"</html>"
		],
		"description": "HTML Template"
	}
}

If you dig into snippets and have any questions, let me know.

Soft Delete not working...?

Having a strange behavior where I get an eloquent object, update it, call save, I can see the old and new values if I dd() it.

Won't commit the change to the database for some reason:
public function hide(Request $request)
{
$note = Note::find($request->id);

    $note->is_active = 0;
    $note->save;

    return redirect('/mynotes');
    
}

P2(website) 403 Forbidden Error

Hi Professor,

The url for my project two shows this error. Below is the copy of the server configuration for this project. How can I fix this?

Please and thank you!
Screenshot 2023-03-20 at 13 48 57
unnamed

Assignment Post: Logging to Slack

I was interested in the logging functionality and wanted to learn more about what I could do with it. From the Laravel documentation, I explored how to log the books a user searched for on Bookmark. I used the Log facade's build method to create an on-demand channel to log to Slack each different book search.

    public function show($title) {

        Log::build([
            'driver' => 'slack', 
            'path' => storage_path('logs/books.log'),
            'url' => 'https://hooks.slack.com/services/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',
            'username' => 'Book Search Log',
            'emoji' => ':book:',
                        
        ])->info('The user looked at the book ' .$title .' on ' .date('d-M-Y'));

        return view('books/show', [
            'title' => $title
        ]);
    }

Screen Shot 2023-03-03 at 10 19 39 PM

I realize this is something I'd probably want to do in config/logging.php but I was nervous to mess with those settings!

Github: https://github.com/andlearnmore/e15/blob/main/bookmark/app/Http/Controllers/BookController.php

phpMyAdmin Not Installing correctly

I'm working on installng phpMyAdmin and am running into an error when trying to make the connection between my server and the phpMyAdmin files. I followed the steps outlined in the vidoe/notes however, when I run the sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin command, I receive an errorr saying that there is no file or director by the name of '/var/www/html/phpmyadmin'.

I uninstalled/reinstalled phpMyAdmin again to double-check I followed the steps correctly, and as far as I can tell, I have. I've included the readouts from my terminal showing the error message I'm getting. I'm not sure why the phpMyAdmin folder isn't being created.

root@HES:/var/www/e15# sudo apt install phpmyadmin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
phpmyadmin is already the newest version (4:5.1.1+dfsg1-5ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 48 not upgraded.
root@HES:/var/www/e15# sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
ln: failed to create symbolic link '/var/www/html/phpmyadmin': No such file or directory

Independent Challenge: Connection could not be established with host

I'm working on the independent challenge and have run into an error message that I don't understand, and can't find information on when I try to research it. I've followed the information in the Laravel Mail documentation and am confused where I've gone wrong. The exact error message I am receiving is:

Connection could not be established with host "mailpit:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

The error occurs in my BookController in the store function when I try to send the email.

    {
        $request->validate([
            'title' => 'required|max:225',
            'slug' => 'required|unique:books,slug',
            'author_id' => 'required',
            'published_year' => 'required|digits:4',
            'cover_url' => 'required|url',
            'info_url' => 'required|url',
            'purchase_url' => 'required|url',
            'description' => 'required|min:100'
        ]);

        $action = new StoreNewBook((object) $request->all());

        $book = Book::where('slug', '=', $request->slug)->first();

        **Mail::to($request->user())->send(new BookAdded($book));**

        return redirect('/books/create')->with(['flash-alert' => 'The book '.$action->results->title.' was added.']);
    }

I'm not sure if the issue is in my mailable, in my mail configuration file, or the actual Store function noted above. Has anyone else ever run into this error?

Testing tools

Just wondering about different testing tools.

The video mentions Dusk is a good tool if you develop locally and Codeception is good for everything except javascript-heavy sites.

Any thoughts for Laravel projects that have frontend frameworks like Vue.js?

Also, should you run different tests with different tools (e.g. HTTP Tests for an API, Codeception for user workflow and Dusk for Vue interactions) or is it better to use one primary tool?

Project 1 code

Hi everyone,

Last week I released Project 1 grades in Canvas, and with all submissions complete I thought I would share the solution code from the P1 demo.

You can view the code here: https://github.com/susanBuck/e15p1

At minimum I recommend taking a scan through the process.php page just to compare/contrast the string processing code to your own solutions.

If you want to share links to your own project code, feel free to reply to this thread and maybe share a bit about your techniques. It's always useful to look at different solutions to the same kind of problem.

Introduce yourself...

Hi everyone -

I wanted to start the semester with a post where everyone can reply with an introduction to themselves so we can get to know each other.

Tell us what brought you to this course and any other details you care to share.

About myself - I'm a web programmer and educator, living in Orange, MA.

In addition to this course, I also teach DGMD E-2. In the past, I've taught at Wellesley, UPenn, and UMiami. When working in industry I was the head developer for an online e-commerce store. Independently, I do private consulting and share free web development guides and videos via https://codewithsusan.com.

More about my background here: susanbuck.net

All in all, I love creating things with code and teaching others how to do the same.

Looking forward to working with you all this semester.

Livewire

Going through the readings this week, one thing that caught my eye was Livewire. In the past I've found it challenging to move to the front-end and incorporate JavaScript into my aps, so something that would spare me having to do that seems like a godsend. I went through the Quickstart section on Livewire's website to get a better sense of it and added a basic "book" counter to my bookmark application.

To add the counter to my page, I created a component using the php artisan make:livewire counter command. It created two folders: 1 in Http (called livewire) and one in my views (also called livewire). The counter came with boilerplate code for the controller file and the views, which you can view here and here, respectively.

To render livewire on your page, you simply have to include the following three lines of code in the view you want it displayed on:

  • @livewireStyles
  • @livewireScripts
  • <livewire:counter />

I chose to display them on my bookmark welcome page:

`@extends('layouts/main')

@section('content')
    @livewireStyles
    @livewireScripts
    <p>How many books would you like to read this year?</p>
    <livewire:counter />
    <p>Welcome to Bookmark. Please check back later.</p>
@endsection`

While the counter isn't particularly impressive, in reading through more of the Livewire doc, the counter only scratches the surface. Down the road when we create more dynamic applications, I imagine that the Actions and Events pages could be very useful.

Week 6 - Sharing Data With All Views

Purpose: I want a way to have common variables available within all pages of my views for a user. For example, "Location" for a bookmarks page.

From readings: Creating & Rendering views

Approach: Set up a new middleware

My thoughts: I haven't done this before so thought it was worth a try. I little more involved that I expected when I first started.

Here is help source: https://laravel.com/docs/10.x/middleware#main-content
My github for bookmark: https://github.com/bar181/e15/tree/main/bookmark
My URL: http://bookmark.bradross.me/tests (this is my testing page so there is no navbar)

STEPS

  1. php artisan make:middleware ShareLocationData
  • new file in Http/Middleware
  1. file: Http/Middleware/ShareLocationData
    -> go to: public function handle(Request $request, Closure $next)
    -> add before the return: session()->put('location', 'Toronto, Canada');

  2. file: Http/Kernel
    -> go to: protected $routeMiddleware
    -> add at end of list: 'share.location' => \App\Http\Middleware\ShareLocationData::class,

  3. file: web
    -> add middleware to end of your route(s)
    -> example: Route::get('/tests', [PageController::class, 'tests'])->middleware('share.location');

  4. file: Http/Controller/PageController
    -> get value in your function and add it to your return
    example: $location = session('location', 'Default Value');
    return view('pages/tests', ['location' => $location]);

  5. Use in your blade tests.blade.php
    example:

    Shared location: {{ $location }}

  6. Results on tests.blade.php
    Shared location: Toronto, Canada

  7. Future use case
    Adjust step 2 (hard coded value) to a query for a specific user

Passing Data on All Views with share()

In order to share data with all views, we can use the view facade's share() method.
This feature can be useful to a project like Book

mark to share data such as $title where this information can be needed in all the pages.

I haven't yet figured out how exactly this method is going to be implemented in my project but I'm currently working on it.

What I do understand is within this function we need to replace
'key' = 'title'
'value' = for the path to get the value of each title. Such as $title.id(?)

public function boot(): void
{
View::share('key', 'value');
}

Reference: (https://laravel.com/docs/10.x/views#sharing-data-with-all-views)

I've also utilised this YT video: https://youtu.be/HWKX48j6ywk

Below I've provided 2 examples of how I've attempted to implement this method in my Bookmark project.

Screenshot 2023-03-07 at 13 42 10

Screenshot 2023-03-07 at 13 59 15

Error with the books table seeder - "Field 'author' doesn't have a default value"

Database\Seeders\BooksTableSeeder ........................................................................................................ RUNNING

Illuminate\Database\QueryException

SQLSTATE[HY000]: General error: 1364 Field 'author' doesn't have a default value (SQL: insert into books (created_at, updated_at, slug, title, author_id, published_year, cover_url, info_url, purchase_url, description) values (2023-04-16 19:39:35, 2023-04-16 19:39:35, the-great-gatsby, The Great Gatsby, 1, 1925, https://hes-bookmark.s3.amazonaws.com/the-great-gatsby.jpg, https://en.wikipedia.org/wiki/The_Great_Gatsby, http://www.barnesandnoble.com/w/the-great-gatsby-francis-scott-fitzgerald/1116668135?ean=9780743273565, The Great Gatsby is a 1925 novel written by American author F. Scott Fitzgerald that follows a cast of characters living in the fictional towns of West Egg and East Egg on prosperous Long Island in the summer of 1922. The story primarily concerns the young and mysterious millionaire Jay Gatsby and his quixotic passion and obsession with the beautiful former debutante Daisy Buchanan. Considered to be Fitzgerald’s magnum opus, The Great Gatsby explores themes of decadence, idealism, resistance to change, social upheaval and excess, creating a portrait of the Roaring Twenties that has been described as a cautionary tale regarding the American Dream.))

Git error when pushing and merging changes

Screenshot 2023-04-23 at 18 42 43

Screenshot 2023-04-23 at 18 43 00

Screenshot 2023-04-23 at 18 46 05

Since I created the prod version of e-15, I've been encountering this problem whenever I attempt to push my code and merge onto my branch. I'm a little bit confused on how to follow the hints suggested from the git-error

Undefined variable $searchTerms

I'm following along with video Part 2 and have run into an error that I can't figure out. I am currently at the part of the video where we are trying to output the $searchTerms to the page, but I keep getting an undefined varialbe for $searchTerms. I've rewatched this part of the video several times and cannot spot my error. As in the video, I'ved updated my BookController as so:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Arr;

class BookController extends Controller
{

    /**
     * GET/search
     * Searches books based on title or author
     */
    public function search(Request $request)
    {

        $bookData = file_get_contents(database_path('books.json'));
        $books = json_decode($bookData, true);

        $searchTerms = $request->input('searchTerms', null);
        $searchType = $request->input('searchType', null);

        
        $searchResults = [];

        foreach($books as $slug=>$book) {
            if(strtolower($book[$searchType] == $searchTerms)) {
                $searchResults[$slug] = $book;
            }
        }

        return redirect('/')->with([
            'searchTerms' => $searchTerms,
            'searchType' => $searchType,
            'searchResults' => $searchResults
        ]);
    }

I've also updated my PageController according to the video:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PageController extends Controller
{
    public function index()
    {
        $searchResults = session('searchResults', null);
        $searchTerms = session('searchTerms', null);
        $searchType = session('searchType', null);

        return view('pages/welcome',[
            'searchResults' => $searchResults,
            'searchTerms' => $searchTerms,
            'searchType' => $searchType,
        ]);
    }
    
    public function welcome()
    {

        $searchResults = session('searchResults', null);
        return view('pages/welcome', ['searchResults' => $searchResults]);
    }

    public function contact()
    {
        return view('pages/contact');
    }
}

And finally, I've attempted to add $searchTerms to my welcome.blade.php file using the "{{ }}" notation, but continue to get an error saying the term is undefined. I assume the issue must be in one of my controller files but I can't spot the error. A fresh pair of eyes would be much appreciated. Thank you!

Week 6 Assignment Post - components and slots

From this week's reading, I found out that you can also create a layout using components and slots. For the Bookmark app, I was able to create a layout and complete the index method using components and slots.

http://bookmark.jacksuwa.online/books/
Review the code below:

bookmark/resources/views/components/layout.blade.php

<!doctype html>
<html lang='en'>

<head>
    <title>{{ $title ?? 'Bookmark' }}</title>
    <meta charset='utf-8'>
    <link href='/css/bookmark.css' type='text/css' rel='stylesheet'>
</head>

<body>

    {{ $header }}

    <section>
        {{ $slot }}
    </section>

    <footer>
        &copy; Bookmark, Inc.
    </footer>

</body>

</html>

bookmark/resources/views/books/index.blade.php

<x-layout>
    <x-slot:title>
        Books
    </x-slot:title>

    <x-slot:header>
        <a href='/'><img src='/images/[email protected]' id='logo' alt='Bookmark Logo'></a>
    </x-slot:header>

    <h4>Showing all the books</h4>
</x-layout>

Components are similar to blade templates as they are reusable and independent. The {{ $slot }} variable contains the content we want to inject into the component. Components can be also used to create reusable alerts, input, and more for the bookmark app.

GitHub: https://github.com/jacksuwa/e15/blob/main/bookmark/resources/views/books/index.blade.php

Error with seeding database - Class "DOMDocument" not found

When I run the command to refresh and seed my database (php artisan migrate:fresh --seed) I get the following error:

  Error 

  Class "DOMDocument" not found

  at vendor/nunomaduro/termwind/src/HtmlRenderer.php:32
     28▕      * Parses the given html.
     29▕      */
     30▕     public function parse(string $html): Components\Element
     31▕     {
  ➜  32▕         $dom = new DOMDocument();
     33▕ 
     34▕         if (strip_tags($html) === $html) {
     35▕             return Termwind::span($html);
     36▕         }

      +23 vendor frames 
  24  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

I am not even sure where to begin with this and would appreciate help! My database is empty, which is the only clue I have.
Thanks!
-Anne

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.