GillesDeb

GillesDeb

Member Since 1 Month Ago

Experience Points
15,300
Total
Experience

4,700 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
129
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 4
15,300 XP
Oct
22
23 hours ago
Activity icon

Replied to Change Model To Eloquent Model > Right Approach?

Oh my (feels like an idiot > hides in shame)... Should have cmd clicked 'Authenticatable' before coming up with my own theories...

Sorry for this stupid question, I was convinced that I needed to change it to an eloquent model (like it was an add-on or something).

Well if there's ever an award for stupid questions, I might be in the running for it with this one :-D

But seriously @sinnbeck , thank you for taking the time to answer and help me understand! Really appreciated!

Activity icon

Replied to Change Model To Eloquent Model > Right Approach?

@sinnbeck, yes correct, I was editing it while you answered :-)

Should be fine now..

But I see that your new model does not extend Authenticatable? Any reason for this?

Correct, well that is a flaw in my knowledge... I thought I could just add that by typing

class User extends Model, Authenticatable {

But that doesn't go :-D

And the default User class is indeed ready for Eloquent out of the box

So wait... I don't have to do anything then??? But my out of the box User model does not have f.ex this :

use Illuminate\Database\Eloquent\Model; 

nor this :

class User extends Model

Activity icon

Started a new Conversation Change Model To Eloquent Model > Right Approach?

Hi guys,

TLDR: I had the idea that I needed to change my User-model to an Eloquent User model. 
It is pointed out that it comes Eloquent ready out of the box.

So up to now, the series I've followed made use of Eloquent models and to my (little) knowledge it seems to be the best approach for my first own 'project' in order to learn more.

This is probably a stupid question, but before I just try my idea of approach I'd like to verify with this amazing community!

When I compiled my bootstrap theme, a user model was provided. After I've added a 'model' folder and put the user-model in that folder.

Now, this user-model needs to be changed to an eloquent model.

This is my current user model :

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
    * The attributes that are mass assignable.
    *
    * @var array
    */
    protected $fillable = [
        'firstname', 'lastname', 'email', 'password',
    ];

    /**
    * The attributes that should be hidden for arrays.
    *
    * @var array
    */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
    * The attributes that should be cast to native types.
    *
    * @var array
    */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

Is it best to delete this user model and just make a brand new one php artisan make:model User -m -f -c

and just add the missing attributes?

Or is it possible to just modify the current user model like this?

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use HasFactory;
    use Notifiable;

    /**
 * The attributes that are mass assignable.
 *
 * @var array
 */
protected $fillable = [
    'firstname', 'lastname', 'email', 'password',
];

/**
 * The attributes that should be hidden for arrays.
 *
 * @var array
 */
protected $hidden = [
    'password', 'remember_token',
];

/**
 * The attributes that should be cast to native types.
 *
 * @var array
 */
protected $casts = [
    'email_verified_at' => 'datetime',
];
}

Both should deliver the same result, or is there a difference / something to keep in mind? What is the best approach of the 2? Or doesn't that matter? Or both not the right way?

Oct
21
1 day ago
Activity icon

Replied to Password Validation Error Message Not Shown

thank you a lot for that.

In the meantime I had read that I had to use the name field "password_confirmation" but did not understand / get / read that (and why) I had to change my validator $data. Which I didn't do, resulting in the reload of page with no error warning.

@rodrigo.pedra Where did you read / how did you know you had to change the validator $data input / conditions?

Thanks again!

Activity icon

Started a new Conversation Password Validation Error Message Not Shown

Hey,

After playing around with my registration, login, reset psw setup I noticed that during registration the passwords were not being verified. (!= identical passwords were still being processed)

Resolved that but now it does not show any message if the passwords are not matched.

This is how my register.blade.php looks like (only part containing psw) :

<div class="form-group">
    <label for="password">Password</label>
    <input class="form-control @error('password') is-invalid @enderror" name="password" type="password" 
    required autocomplete="new-password" placeholder="Enter your password">
                                        
    
    @error('password')
        <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
        </span>
    
    @enderror
</div>

<div class="form-group">
    <label for="password-confirm">Confirm password</label>
    <input class="form-control" name="confirm_password" type="password" 
    required id="password-confirm" autocomplete="new-password" placeholder="Confirm your password">                                       
</div>

This is how the validator is set up :

protected function validator(array $data)
{
    // dd($data);
    return Validator::make($data, [

        'firstname' => ['required', 'string', 'max:255'],
        'lastname' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'password' => ['required', 'string', 'min:8', 'required_with:confirm_password|same:confirm_password'],
        'confirm_password' => ['required', 'string', 'min:8'],

    ]);
}

Before I'm trying to fetch it to far, did i make a mistake in the validator function?

Oct
20
2 days ago
Activity icon

Replied to Reset Password Fails > Update Not Solved

@nakov thanks for that!

I seem to always overlook small details like these and immediately go to far (=deep down the rabbithole) with searching for a solution...

Let's hope I learn from it ;-)

Thnx again!

Activity icon

Replied to Reset Password Fails > Update Not Solved

Just trying to figure out the issue, shouldn't I change the email.blade.php "enter-email-to-reset-section" from this :

<form method="POST" action="{{ route('password.email') }}">
    @csrf
    <div class="form-group mb-3">
    <label for="emailaddress">Email address</label>
    <input class="form-control" type="email" 
                 id="emailaddress" required="" placeholder="Enter your email">

     </div>

      <div class="form-group mb-0 text-center">
         <button class="btn btn-primary" type="submit">Reset Password</button>
       </div>
    </form>

To an action on my submit button? I mean I can't figure out when the route password/reset/{token} is being called...

Activity icon

Replied to Reset Password Fails > Update Not Solved

@nakov Sorry for that, I wasn't sure if I was doing it correctly, hence my initial question (more to be sure that I was on the right path).

This is my .env mail_mailer section :

MAIL_DRIVER=log
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

The log file 'laravel.log' does contain 13k rows of previous exceptions but no email is shown.

The ForgotPasswordController is left untouched :

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    use SendsPasswordResetEmails;
}

I DO NOT have a sendResetLInkEmail file, as its named SendsPasswordResetEmails.php

<?php

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;

trait SendsPasswordResetEmails
{
    /**
    * Display the form to request a password reset link.
    *
    * @return \Illuminate\View\View
    */
    public function showLinkRequestForm()
    {
        return view('auth.passwords.email');
    }

    /**
    * Send a reset link to the given user.
    *
    * @param  \Illuminate\Http\Request  $request
    * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
    */
    public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $this->credentials($request)
        );

        return $response == Password::RESET_LINK_SENT
                    ? $this->sendResetLinkResponse($request, $response)
                    : $this->sendResetLinkFailedResponse($request, $response);
    }

    /**
    * Validate the email for the given request.
    *
    * @param  \Illuminate\Http\Request  $request
    * @return void
    */
    protected function validateEmail(Request $request)
    {
        $request->validate(['email' => 'required|email']);
    }

    /**
    * Get the needed authentication credentials from the request.
    *
    * @param  \Illuminate\Http\Request  $request
    * @return array
    */
    protected function credentials(Request $request)
    {
        return $request->only('email');
    }

    /**
    * Get the response for a successful password reset link.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  string  $response
    * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
    */
    protected function sendResetLinkResponse(Request $request, $response)
    {
        return $request->wantsJson()
                    ? new JsonResponse(['message' => trans($response)], 200)
                    : back()->with('status', trans($response));
    }

    /**
    * Get the response for a failed password reset link.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  string  $response
    * @return \Illuminate\Http\RedirectResponse
    *
    * @throws \Illuminate\Validation\ValidationException
    */
    protected function sendResetLinkFailedResponse(Request $request, $response)
    {
        if ($request->wantsJson()) {
            throw ValidationException::withMessages([
                'email' => [trans($response)],
            ]);
        }

        return back()
                ->withInput($request->only('email'))
                ->withErrors(['email' => trans($response)]);
    }

    /**
    * Get the broker to be used during password reset.
    *
    * @return \Illuminate\Contracts\Auth\PasswordBroker
    */
    public function broker()
    {
        return Password::broker();
    }
}

weird thing is that it seems to not even validate the email in the input form. Just whatever email typed in, it doesn't even check if it is stored in the database.

Activity icon

Replied to Reset Password Fails > Update Not Solved

@nakov not using the route recoverpassword, trying to use the predefined routes.

predefined routes :

	{{ route('password.request') }}
	{{ route('password.email') }}

Anything in particular I need to show you?

Activity icon

Replied to Reset Password Fails > Update Not Solved

@nakov, yes that is what I thought, which resulted in me checking my routes list

php artisan route:list

There I saw the predefined routes and saw that they were already set. Hence my very simple question if it is fine just to change my blade files to to correct naming instead of changing the route naming.

Turns out it works both ways, so assume both ways are correct. I just don't want to mess something up in the long run. But might overthink this :-)

Activity icon

Started a new Conversation Reset Password Fails > Update Not Solved

Hi,

I'm having difficulties to get my authentication working. Registering and Login work fine. But as soon as I try to sort the "Reset password" I'm not getting the results as expected.

Basically, when clicking the reset password button, nothing happens. My log show no incoming mail, nor does the databasetable show a password reset; token, etc...

I've probably explained my issue wrong before, hence the update.

Any help is, as always, appreciated.

My routes regarding this issue :

	POST     | password/email           | password.email   | App\Http\Controllers\Auth\[email protected]  | web       

GET|HEAD | password/reset           | password.request | App\Http\Controllers\Auth\[email protected] | web 

POST     | password/reset           | password.update  | App\Http\Controllers\Auth\[email protected]                | web

GET|HEAD | password/reset/{token}   | password.reset   | App\Http\Controllers\Auth\[email protected]        | web

My login.blade.php "forgot-password-section" :

<div class="form-group">
       <a href="{{ route('password.request') }}" class="text-muted float-right">
	<small>Forgot your password?</small>
   </a>
       <label for="password">Password</label>
       <input class="form-control" name="password" type="password" required=""
                   id="password" placeholder="Enter your password" />

    </div>

My email.blade.php "enter-email-to-reset-section" :

<form method="POST" action="{{ route('password.email') }}">
       @csrf
        <div class="form-group mb-3">
        <label for="emailaddress">Email address</label>
        <input class="form-control" type="email" 
                     id="emailaddress" required="" placeholder="Enter your email">

         </div>

          <div class="form-group mb-0 text-center">
             <button class="btn btn-primary" type="submit">Reset Password</button>
           </div>
        </form>
Oct
19
3 days ago
Activity icon

Replied to Models Folder -> Failed To Open Stream : No Such File

Thank you thank you thank you!

Had to update the namespace in the auth.php file.

Ive manually changed the vendor directory again, and did as you told.

thnx!

Activity icon

Started a new Conversation Models Folder -> Failed To Open Stream : No Such File

Hi all,

Decided to make a models folder, but turns out it is a pain in the ....

So the User.php file is now under :

app/Models/User.php

As to before it was under :

app/User.php

Since making this change I get the following ErrorException:

include(/path/path/path/path/vendor/composer/../../app/User.php): failed to open stream: No such file or 		directory

I did change my RegisterController.php to :

use App\Models\User;

No result

No idea what composer/../../app/User.php is all about. but under the vendor/composer/ folder there is a file named :

autoload_classmap.php

In this file I've updated the line :

App\User' => $baseDir . '/app/User.php',

to:

App\Models\User' => $baseDir . '/app/Models/User.php',

Still the same error. Clearly I'm overlooking something here, but can you help me where to search?

Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

@michaloravec any motive to why I should prefer ternary operators?

Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

OMG sorry for that and thank you.

was so focussed on just that block of code, I never noticed (or thought of) this typo.

Sorry for this guys, but thank you all for the effort to help!!!

Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

@michaloravec ok here is the complete file:

it contained a typo

goes and hides in shame now ;-)

Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

@sinnbeck thought so too at first but line 29 is fine as well (line 30 is empty); basically learned that it's best to check the whole script after being pointed to a typo.

Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

@a4ashraf changed as you suggested to no avail..still some ParseError line 31 which looks like this

  @if(session('error'))

line 32 :

<div class="alert alert-danger">{{ session('error') }}</div>

line 33 :

 <br>@endif
Activity icon

Replied to Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

@automica no sorry it was on another line

@if(session('error'))<div class="alert alert-danger">{{ session('error') }}</div>

                        <br>@endif
Activity icon

Started a new Conversation Syntax Error, Unexpected 'error' (T_STRING), Expecting ')'

Hey,

I get this ParseError (see title) for my view : path/resources/views/auth/login.blade.php

Illuminate\Filesystem\Filesystem::Illuminate\Filesystem\{closure}
resources/views/auth/login.blade.php:31

Line 31 seems to be fine to me, so not really sure why it expects a ')'

@if(session('error'))<div class="alert alert-danger">{{ session('error') }}</div>

Can someone point me in the right direction?

Oct
18
4 days ago
Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

This was not necessary, tried another way to set it up (importing resources and compile using laravel mix). Works like a charm now; no additional tweaking was needed

Oct
10
1 week ago
Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft So for every font I would need to do like :

<link rel="stylesheet" href="{{ asset('fonts/dripicons-v2.eot') }}">
<link rel="stylesheet" href="{{ asset('fonts/dripicons-v2.svg') }}">
etc

I can do

<link href="{{ asset('fonts' ) }}">

But the font are not loaded

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft

<link rel="stylesheet" href="{{ asset('fonts') }}">

Sorry i changed it, example before was:

<link rel="stylesheet" href="{{ asset('public/fonts') }}">

Otherwise I have no idea what you mean with 'show full css' -> "fonts" is a folder under public that contains all the fonts

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft

❗️Apologies for that ❗️

This URL http://test.test/fonts not load, what is the FULL URL that is giving the problem?

Isn't that the full URL? Basically in Chrome dev tools it shows as a css-file instead of a folder that can be expanded and containing the different fonts. See : https://imgur.com/a/ujrkpLD

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

Hey @laracoft!

  • No matter what I try, the same error keeps showing up. No matter how I change my path

All fonts are stored in public/fonts

It throws the error 'failed to load resource: server responded with a 404 -> http://test.test/fonts

-> whenever I change my path, the 404 error adjusts to the path...

  • Yes both errors are bootstrap issues, although 1 refers to bootstrap.js which I deleted (not added by me) and the error still comes up :-D like wth??

The other error is a syntaxerror, unexpected token ':' -> checked the js file, but no :-type or anything...

What can I show you / give you in order to help me resolve the fonts path?

Should I really care about the 2 bootstrap errors?

Oct
09
1 week ago
Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft can I ask you a hint 😇

Regarding the fonts > So I think something is wrong with the path as you can see in the following screenshot (https://imgur.com/a/4G6w6c8)

So for a strange reason it doesn't detect the 'fonts'-folder (like it does with css/img/js). Also if I look under the network tab (chrome dev tool) the type is css (shouldn't that be eot/svg/ttf/woff)? and transfer size = --, time 35,4ms

* Any hint?

Lastly, step 1-3 -> excellent, I got all the errors removed now but 2 new ones came up by themselves. See here ( https://imgur.com/a/4G6w6c8 )

* Is this a sign some files are still missing?
Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft Ok, thnx for taking time and help me forward/understand better! You've helped me a lot already kind stranger, I'd buy you a beer irl!

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft

Ok, I'll try step 1/2 for the css and js... makes sense

Can you explain me the following please :

  • Although I understand that the files are missing as I clearly did not put them in the public folder. I did put all my fonts in the public/fonts folder and that throws an error too.

-- > What more is there to add (checked and this folder i did copy completely)

  • On Wednesday I only copied a few css and js assets from the bootstrap theme and pasted them first under resources css/ and js/. This was wrong as I needed to put these in the public folder as it needs to be accessible for users (Hope this is right, as this is how I understood :p )

-- > Did I understand it indeed correctly or not?

What sorcery is this! Am I correct that I'll need to check this later and remove it (for security)?

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft Oh no, I think I screwed up big...

To answer :

You mentioned putting CSS and JS into the public/css and public/js, what files are you putting there? 
I mean if you don't have /js/vendor.min.js, then don't let it load inside the blade.php file.

On Wednesday I only copied a few css and js assets from the bootstrap theme and pasted them first under resources css/ and js/.

This was wrong as I needed to put these in the public folder as it needs to be accessible for users (Hope this is right, as this is how I understood :p )

Regarding :

Look under the dist folder for the js that you are compiling/building

My god there are the missing files, but there are so many!!! with subfolders like pages/ui and vendor

the map files are used to break up the JS/CSS files by the browser into the original separate files.
Usualy for purpose of debugging.

Ah I see, well I have to admit these are indeed under the dist/assets/js folder...

The font folder, you can't really load it in html, do you get what i mean?

èh, not sure... I mean, the folder itself would be difficult to load as it contains several different fonts of which each fonts has approx 3 different extensions. But I assumed that the css stylesheet guides the browser to the correct font, but that seems to be just me making things up?

This is everything under the dist folder (https://imgur.com/a/3hoHVE1), can you explain me what I had to copy?

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

@laracoft

Well i though they exist I've added them with your help 2 days ago (shorturl.at/kJLU0) The folder yes, the other files : no vendor file found and nothing ending with a .map extension...

http://test.test/public/fonts // this is a folder --> Yes, but the folder contains all fonts (https://imgur.com/a/BpxE9EI)

http://test.test/js/vendor.min.js // does public/js/vendor.min.js exists?

-->No, I must have done something wrong here, do I just copy the whole js/vendor file from the bootstrap theme and paste that in the public folder? In this case do I also do that with the ui and pages folder (both are under the js folder of the theme)

--> same for the .map extensions... but i don't have files named like this 0_O so why does it look for a .map?

I probably did something wrong wednesday during the bootstrap integration :( Was so focussed on getting most of the layout right, but I assume I did not copy enough from the template. However there is so much to copy in that case that I don't know what is necessary to copy

https://imgur.com/a/K4TPVCr this is the whole theme folder

Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

Hey @laracoft!

Browser returns:

User-agent : *
Disallow:
Activity icon

Replied to Failed To Load Resource (404) > Partly Solved

Hey @drewdan I've put the css and js scripts directly in the public folder and resources folder. The fonts I've put directly in the public folder.

I can't upload a pic here, but did so on imgur : https://imgur.com/a/BpxE9EI

Activity icon

Started a new Conversation Failed To Load Resource (404) > Partly Solved

Hey all,

Here again with another question, I'm experiencing errors in the inspector element stating for several assets :

failed to load resource: the server responded with a status of 404 (Not Found)

This is the case for 5 assets

  1. http://test.test/public/fonts
  2. http://test.test/js/vendor.min.js
  3. http://test.test/css/icons.min.css.map
  4. http://test.test/css/app-dark.min.css.map
  5. http://test.test/css/app.min.css.map

These are my paths, which should be correct...

	<!-- Fonts -->

    <link href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap" rel="stylesheet">
     <link rel="stylesheet" href="{{ asset('public/fonts') }}">

<!-- JS -->

<script src="{{ asset('js/vendor.min.js') }}"></script>
<script src="{{ asset('js/app.min.js') }}"></script>
<script src="{{ asset('js/main.js') }}"></script>
<script src="{{ asset('js/bootstrap.js') }}"></script>
<script src="{{ asset('js/app.js') }}"></script>
<script src="{{ asset('js/app.min.js.map') }}"></script>

I'm not sure as to why only 1 js script is thrown up as an error..

	<!-- App css -->
    
    <link rel="stylesheet" href="{{ asset('css/icons.min.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ asset('css/app.min.css') }}" type="text/css" id="light-style">
    <link rel="stylesheet" href="{{ asset('css/app-dark.min.css') }}" type="text/css" id="dark-style">
    <link rel="stylesheet" href="{{ asset('css/style.css') }}">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">

Same here, but seems that it's only my imported bootstrap stylesheets that are off.

The fonts assets have the following path : public/fonts/allfontsplacedhere The css assets have the following path : public/css/allcssstylesheetsplacedhere The js assets have the following path : public/js/alljsstylesheetsplaceshere

Beside these errors i also got 4 other .js errors but expect that this is related to the above.

Are my paths really incorrect?

I've posted a few pics on imgur if you think it's necessary to see my map structure https://imgur.com/a/BpxE9EI

Activity icon

Replied to Why Are My Includes Not In The Right Order?

Aw yes! now it's good and I think I get it. So lets say I have 3 pages (home/about/contact) The best approach is to make an app.blade.php file and do like following :

    <!-- test -->
<html>
    <head>

    </head>
    <body>
        @include('layouts.header')
        @include ('layouts.navbar')
    
        @yield ('content')
    
        @include ('layouts.footbar')
        @include ('layouts.footer')
    </body>
</html>

And for those 3 pages :

@extends('layouts.app')

@section('content')
		<h1>here is my content</h1>
@endsection 

If for the application itself there is a genereal layout with f.ex sidebars etc.. I just make another layoutfile (similar to app.blade.php) give it the same structure with the includes I need.

Thank you for clarifying this for me, it was probably a very simple question, but it takes me a bit more to understand it. Since starting to learn programming in general besides being overwhelmed by everything, I feel a lot dumber ^.^ let's hope it's temporary xD

Again thank you @michaloravec for taking the time to help me understand. Appreciated!

Activity icon

Replied to Why Are My Includes Not In The Right Order?

@michaloravec Really sorry for this but I tried to follow your advice and made an app.blade.php file.

This file contains :

<!-- test -->

@include('layouts.header')
@include ('layouts.navbar')
@section ('content')
@yield ('content')
@endsection
@include ('layouts.footbar')
@include ('layouts.footer')

So not extend but include as I'll have other files in the future where f.ex the navbar is not included but I'll include a sidebar.

I understand you recommended this, as it is easy for multiple pages with identical layout right?

My welcome.blade.php now has on top the code

@extends ('layouts.app')

In browser content is shown but now my navbar is at the bottom...

If I change the app.blade.php to :

<!-- test -->

@include('layouts.header')
@include ('layouts.navbar')

@yield ('content')

@include ('layouts.footbar')
@include ('layouts.footer')

And the welcome.blade.php to :

@extends ('layouts.app')
    @section ('content')
	.... content
@endsection

the layout order is fine, but it repeats multiple times and styling is off

Activity icon

Replied to Why Are My Includes Not In The Right Order?

Thnx @michaloravec for your reply!

I'm not really understanding why I need to create an app.blade.php and put the 4 @extends in that file. If on another page I don't want to include the f.ex. navbar and bottombar but include a sidebar) I would need to make another file f.ex. app2.blade.php which doesn't seem to make sense to me...

I really try to understand the docs, but I just have a really hard time to understand the explanation. It's not as clear to me as I assume it is for others... It confuses me more... I tried searching for older posts like one you replied to (https://laracasts.com/discuss/channels/laravel/laravel-blade-at-include-vs-at-extends?page=0) but since I'm coming off the Laravel from scratch course (sec4) your explanation and/or the one from docs is different.

So to be 100% sure, my approach of creating a resources/views/layouts folder to store all my layouts that need to be included multiple times is not the best approach?

Activity icon

Started a new Conversation Why Are My Includes Not In The Right Order?

Hi,

I think I might follow the wrong approach for my includes.

I'm currently trying to understand how to work with include files. My index page only contains the content and uses includes from 4 different files (stored in a layouts folder) : header.blade.php navbar.blade.php footbar.blade.php footer.blade.php

So my index page is as follows

@extends ('layouts.header')
@extends ('layouts.navbar')
@section ('content')
	<h1>here's my content </h1>
@endsection
@extends ('layouts.footbar')
@extends ('layouts.footer')

Strangely enough my footbar-include comes right at the top of my index page.

The 4 includes files only contain the script that needs to be includes, but in the "header.blade.php" at the bottom I've put @yield('content')

If I put this on top in the "footbar.blade..." the footbar drops to the right place but my navbar drops to the bottom...

Why is this order messed up? Am I putting the "@yield ('content') in the wrong file/place?

Thnx in advance,

Oct
07
2 weeks ago
Activity icon

Replied to Laravel And Bootstrap Integration

Aah I see, well babysteps first ;-) thnx for the help!

Activity icon

Replied to Laravel And Bootstrap Integration

U Legends @laracoft @thewebartisan7 !! Now i'm getting there!

One follow up question, a few weeks ago i had this advice under a question posted by me :

you shouldn't need to be interacting with css in your public directory. To edit css, you should be modifying app.css inside /resources/app.css and then running 'npm run watch' to watch changes and then publish to /public/css/.

if you've modified /public/css/app.css and have 'npm run watch' running, you'll be overwriting your changes with those inside resources, and this will clear out any css you've run.

Does this mean I just have duplicates in the resources folder and make the changes there? = not touch the public/css but only resources/ccs/duplicate if I want to make a change?

Activity icon

Replied to Laravel And Bootstrap Integration

@laracoft

* I understand, but I followed the tutorial 'how to get started' (linked above) and no app.blade.php view was available

* Yes, I use layout.blade.php because that is what i added (only welcome.blade.php was premade) I can change it to app.blade.php but don't understand what the difference would be

* It's no issue how the file is named, more important to get it working, but think I must be missing something as you refer to the app.blade.php... that should be in views right? In that case, I didn't have it from the start --> was following the tutorial to integrate bootstrap a mistake? Looks like my views file should have a 'layouts' folder in which the app.blade.php is. Is that right? In that case, that's what I'm missing...

my question is, are you able to get it to show in your browser?

Yes, i can output in my browser. However it is just plain html not bootstrap styling

I tried the following :

<!-- App css -->
    
    <link rel="stylesheet" href="{{ asset('css/icons.min.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ asset('css/app.min.css') }}" type="text/css" id="light-style">
    <link rel="stylesheet" href="{{ asset('css/app-dark.min.css') }}" type="text/css" id="dark-style">
    <link rel="stylesheet" href="{{ asset('css/style.css') }}">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">

^ I added the app.css in the stylesheet, resulting in a partly convert to the bootstrap layout. However large sections are just plain. Taking this in account, I also put all the scripts from the resources/js folder and put them below in the code. This did not change a thing though.

<script src="{{ asset('js/vendor.min.js')"></script>
<script src="{{ asset('js/app.min.js')"></script>
<script src="{{ asset('js/main.js')"></script>
<script src="{{ asset('js/bootstrap.js')"></script>
<script src="{{ asset('js/app.js')"></script>
<script src="{{ asset('js/app.min.js.map')"></script>
Oct
06
2 weeks ago
Activity icon

Replied to Laravel And Bootstrap Integration

@laracoft

  1. NO

This is my layout.blade.php file (should be renamed header.layout.blade.php)

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- App css -->
    
    <link rel="stylesheet" href="{{ asset('css/icons.min.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ asset('css/app.min.css') }}" type="text/css" id="light-style">
    <link rel="stylesheet" href="{{ asset('css/app-dark.min.css') }}" type="text/css" id="dark-style">
    <link rel="stylesheet" href="{{ asset('css/style.css') }}">

<!-- Fonts -->
        <link href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="{{ asset('public/fonts') }}">

<!-- App favicon -->
    <link rel="shortcut icon" href="{{ asset('img/favicon.ico') }}">

<!-- page title -->
    <title>TEST</title>
</head>
@yield ('content')

And this is a small part of my welcome.blade.php

<section class="hero-section">
        <div class="container">
            <div class="row align-items-center">
                <div class="col-md-5">
                    <div class="mt-md-4">

result: it just shows plain html

edit: maybe this helps? https://imgur.com/a/QCNnoDd its a structure of the bootstrap template and screenshots of how i implemented it into laravel project

Activity icon

Replied to Laravel And Bootstrap Integration

@laracoft èh I might be a fool here but I don't have an app.blade.php, nor home.blade.php..

I just have 1 which is welcome.blade.php (under the views folder). I just made a subfolder here for my 'layout' pages. as I want an include for header, footer, sidebar, navbar, etc... so in that subfolder I can make all my separate layoutpages f.ex. navbar.layout.blade.php.

regarding this :

Paste the full HTML of the page you want to start with into app.blade.php

Unfortunately I already cut the main layout in different include files when i started this project before learning Laravel. Therefore I'm going to try the above steps (put all includes in a layout subfolder) and hopefully I'll be able to add the mall to my welcome.blade.php file and see the correct output. I'll keep you updated!

Again, thank you very much for your effort to reply and help me out. It's really appreciated!!

Activity icon

Replied to Laravel And Bootstrap Integration

Hey @laracoft,

Sorry it is indeed a chunky block of text... Basically I just don't understand where to start after following the tutorial linked above.

So I'm quite unsure if I did good by just copying the files and pasting them where I think they belong. So in the meantime I did the following :

in public folder :

added a 'fonts' folder (=> pasted all the fonts in there)
added a 'img' folder (=> pasted all the img/svg in there)

In the resources folder :

in the css folder => pasted all the .css files
in the js folder => pasted all the .js files

Can you tell me if this is the correct approach?

NB: Following your reply, I do think I started a similar approach.

> created a layout.blade.php file in the views folder
Activity icon

Started a new Conversation Laravel And Bootstrap Integration

Hi all,

As I'm trying to start my first project using Laravel, I'm starting to feel very overwhelmed. What I thought would be an easy start, is turning out to be confusing and a rabbit hole?

So a while ago I bought a bootstrap theme : https://themes.getbootstrap.com/product/hyper-responsive-admin-dashboard-template/

Partly for practice, but also having the intended project in mind. I actually started learning basic vanilla php, oophp, making a 'basic' framework, to recently (+/- 2 weeks) getting into laravel.

This is all very quick I know... but the goal is to start with a project that I have in mind for a longer time and I decided to just go for it, instead of thinking about it.

Although I feel I still struggle with understanding some (several) aspects of Laravel, I just want to get some progress. Learn along the way, maybe get a very simple start of the project live, and keep developing / learning further as more users are (hopefully) joining.

Now before (= when using the custom framework) I had a public folder which contained:

  • css (+/- 4 css files)
  • fonts (+/- 25 .ttf / .woff, etc files)
  • img (all my page images)
  • js (7 js files + 2 folders).

I used the following method to get started with laravel and bootstrap : https://medium.com/@shrijan00003/the-preferred-way-of-using-bootstrap-with-laravel-7-8e51ba845574

However do I just add the files in the respective folder (even create the missing folder(s))?

I tried searching through Laracasts, but couldn't find a course in which they only use laravel & bootstrap. Seems like a lot of 3rdparty(?) options are being used during these tutorials/courses

Thanks for the feedback,

Really appreciated

Oct
01
3 weeks ago
Activity icon

Replied to Migration Is Failing, Error Sqlstate42501 Base Table/view Already Exists

Ooh, so i only had to add

 'Schema::dropIfExists('article_tag');'

? Didn't realise it was necessary to do this from the start, makes sense to reverse the migration..

I've separated them and it worked like a charm (down method filled in automatically).

Tried your suggestion, now it works like a charm too!

!! Thnx @automica & @sinnbeck !!

Activity icon

Replied to Migration Is Failing, Error Sqlstate42501 Base Table/view Already Exists

@sinnbeck héhé that worked but how come I can't do it at once (as shown in the tutorial)?

Activity icon

Replied to Migration Is Failing, Error Sqlstate42501 Base Table/view Already Exists

@automica Yes, quite sure about that:

Models>Tag.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
	use HasFactory;
}

Migrations>create-tags-table.php

<?php

use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

class CreateTagsTable extends Migration

{

/**

 * Run the migrations.

 *

 * @return void

 */

public function up()

{

    Schema::create('tags', function (Blueprint $table) {

        $table->bigIncrements('id');

        $table->string('name')->unique();

        $table->timestamps();

    });

    // Article_tag (pivot table)
    Schema::create('article_tag', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->unsignedBigInteger('article_id');
        $table->unsignedBigInteger('tag_id');
        $table->timestamps();

        //avoid duplicates
        $table->unique(['article_id', 'tag_id']);

        //set up foreign keys
        $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
        $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::dropIfExists('tags');
}

}

Activity icon

Replied to Migration Is Failing, Error Sqlstate42501 Base Table/view Already Exists

@automica first try i ran

php artisan migrate

As that did not go to plan, I tried

php artisan migrate:fresh

This resulted in all tables dropped and migrations created successfully. However:

in the list of migrated tables the table (tags_table) is not being migrated...

Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (15.27ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (14.35ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (15.38ms)
Migrating: 2020_09_26_141602_create_posts_table
Migrated:  2020_09_26_141602_create_posts_table (8.91ms)
Migrating: 2020_09_26_142800_create_projects_table
Migrated:  2020_09_26_142800_create_projects_table (6.12ms)
Migrating: 2020_09_26_142926_create_assignments_table
Migrated:  2020_09_26_142926_create_assignments_table (6.69ms)
Migrating: 2020_09_28_113244_create_articles_table

And I get the error as in my original posts.

After I tried running the command

php artisan migrate:rollback

followed by

php artisan migrate 

Migrating: 2020_09_28_113244_create_articles_table

Migration failed almost instantly got the error (sqlstate 42501)as above. it seems to get stuck or something over the same table... (which worked fine before, so not really understanding why it gives me an error now)

After I tried :

php artisan migrate:refresh

Seems like it was going well :

Rolling back: 2020_09_26_142926_create_assignments_table
Rolled back:  2020_09_26_142926_create_assignments_table (7.09ms)
Rolling back: 2020_09_26_142800_create_projects_table
Rolled back:  2020_09_26_142800_create_projects_table (1.32ms)
Rolling back: 2020_09_26_141602_create_posts_table
Rolled back:  2020_09_26_141602_create_posts_table (1.96ms)
Rolling back: 2019_08_19_000000_create_failed_jobs_table
Rolled back:  2019_08_19_000000_create_failed_jobs_table (5.01ms)
Rolling back: 2014_10_12_100000_create_password_resets_table
Rolled back:  2014_10_12_100000_create_password_resets_table (4.83ms)
Rolling back: 2014_10_12_000000_create_users_table
Rolled back:  2014_10_12_000000_create_users_table (4.53ms)
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (15.70ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (14.85ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (16.07ms)
Migrating: 2020_09_26_141602_create_posts_table
Migrated:  2020_09_26_141602_create_posts_table (6.54ms)
Migrating: 2020_09_26_142800_create_projects_table
Migrated:  2020_09_26_142800_create_projects_table (12.22ms)
Migrating: 2020_09_26_142926_create_assignments_table
Migrated:  2020_09_26_142926_create_assignments_table (9.88ms)
Migrating: 2020_09_28_113244_create_articles_table

But ended up with same sqlstate error

I thought maybe to try and give a path :-) but that command did not exist...

php artisan migrate --path:/database/migrations/2020_10_01_103530_create_tags_table.php
Activity icon

Started a new Conversation Migration Is Failing, Error Sqlstate42501 Base Table/view Already Exists

Hi,

My migration process fails, as in all the tables I created before today are being migrated. The table I created today fails to migrate. I do get an error thrown :

 Illuminate\Database\QueryException 

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'articles' already exists (SQL: create table articles (id bigint unsigned not null auto_increment primary key, user_id bigint unsigned not null, title varchar(255) not null, excerpt text not null, body varchar(255) not null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

This seems to refer to a table that does migrate, but I'm not getting why that error is getting thrown now...

In my migrations folder the create table file (for the missing table) is as follows :

public function up()
{
    Schema::create('tags', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name')->unique();
        $table->timestamps();
    });

    // Article_tag (pivot table)
    Schema::create('article_tag', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->unsignedBigInteger('article_id');
        $table->unsignedBigInteger('tag_id');
        $table->timestamps();

        //avoid duplicates
        $table->unique(['article_id', 'tag_id']);

        //set up foreign keys
        $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
        $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
    });
}

In the Article Model I created a manytomany relationship by :

 public function tags(){
    return $this->belongsToMany(Tag::class);
}

Anyone can steer me in the right direction?

Sep
29
3 weeks ago
Activity icon

Replied to !=deployed: Connection To Site Is Not Secure > Should I Be Worried

@laracoft Interesting, thnx for taking the time to help me understand the subject a bit better. At least I know that for now, I'm quite 'secure' but will have to go deeper into the subject later on (to-do post-its everywhere ^^ )

Thank you again