Snapey

Director at Novate Ltd

Member Since 6 Years Ago

Mansfield

Experience Points
2,033,345
Total
Experience

0 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
1415
Lessons
Completed
Best Reply Awards
2872
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 50
2,033,345 XP
Oct
30
19 hours ago
Activity icon

Replied to Livewire Performance

Why would Livewire care about pusher?

They should not be related.

Activity icon

Replied to No Video With Supported Format And MIME Type Found

I uploaded a video

to where? Youtube? facebook? your mum's website?

You should know better by now.

Activity icon

Replied to Modal View With Livewire Or Alpine

create a component for the modal.

Show it and send an event to the component telling it which record to show.

for instance, in a table, on the table row, I have

wire:click="$emit('selectJourney',{{ $journey->id }})" 

select journey function in the modal component receives the id of the record to show in the modal

edit: sorry, in this case, the modal is part of the same component as the table, so the $emit goes to the same livewire component. If you want to create a component just for the modal then you have to do a event to the window

Activity icon

Replied to Null When I Dd

@sinnbeck can I just shoot the breeze with you incase something comes up that I had not mentioned before?

Activity icon

Replied to Custom FormRequest Validation Without DI

Why can you not do the switch in the request class?

The rules() method returns an array. That does not need to be all it does.

The returned rules array can be built on the fly based on other aspects of the request.

Activity icon

Replied to Need To Register/authenticate Two Types Of Users In The Same Laravel App

OK, you can still use a single User model and users table, have the one guard

just needlessly duplicate the login controller and forms etc

Activity icon

Awarded Best Reply on Jetstream/Livewire 2 - Undefined Variable: Header

You don't need to include the <x-app-layout> since livewire already includes that. So you end up with x-app-layout inside x-app-layout with the outer one not receiving the $header

In your component view change x-app-layout for a div (since you still need a single root element) and you should be good.

Activity icon

Replied to Jetstream/Livewire 2 - Undefined Variable: Header

You don't need to include the <x-app-layout> since livewire already includes that. So you end up with x-app-layout inside x-app-layout with the outer one not receiving the $header

In your component view change x-app-layout for a div (since you still need a single root element) and you should be good.

Activity icon

Replied to Need To Register/authenticate Two Types Of Users In The Same Laravel App

but as I need to have separate authentication pages, for the customers and for the admins,

Why do you?

Oct
29
1 day ago
Activity icon

Replied to My Dd($products) Is Getting Anull Value

Your relationship seems messed up.

If a Category has many products then the products table should have a column called category_id

if dd($products) is null then its because there is no category with the ID you passed.

Your variable ought to be called $category since you are finding a single ProductCategory

Activity icon

Replied to HasMany Is Not Getting Results

watch out for things like this;

1 )

Route::get('/contracts/{custoner}', [ContractsController::class, 'show']);

you miss-spell customer

2 )

public function show() {
        
        return view('contracts.show', ['allContracts' => $this->customers->contracts()]);
    }

your show method does not accept the customer that you passed in the route

3 )

$this->customers = new Customers;
  • models should by convention be singular. A model represents a single record.
  • not sure why you are setting up an empty model in the constructor? This is unnecessary.
  • if a variable holds a single record then it should be named singular not plural
Activity icon

Replied to Array To String Conversion

You are validating twice

        $data = $this->validate();

        $post = Auth::user()->posts()->create(
        $this->validate() + 
        ['slug' => Str::slug($data['title'], '-')]
        );

Just write out the elements you need from the $data instead of trying to throw the whole $data into the create method.

eg

        $data = $this->validate();

        $post = Auth::user()->posts()->create([
            'slug' => Str::slug($data['title'], '-'),
            'field2' => $data['field2'],
            'field3' => $data['field3'],
//etc
        );


Activity icon

Replied to Delete Not Working

never delete using a simple link. Always use a form.

Also make sure you have authorization on the route, else anyone can delete your users.

Name things for what they are. If you are deleting a user then call it $user not $data

Activity icon

Replied to Multiple Database Consult In One

Sure

You prepare the data you need for your view in the controller.

public function index()
{
	return view('myindex.view')
            ->withBooks(Books::all())
            ->withCars(Cars::all())
            ->withColors(Colors::all());
}

with the above syntax you have $books, $cars and $colors available to you in the view

Activity icon

Replied to How Do I Host Laravel And Inertiajs App In CPanel?

If public_html is the folder to be served by your webserver, one option is to delete it and then recreate it as a symbolic link from public_html to your laravel project public folder.

Alternatively, rename public to public_html in your development environment. Make sure it all works still then upload to the root folder of your shared hosting.

Activity icon

Replied to Find The Individual Photos That Make This Video

The images are all embedded in the initial html page. They are not loaded as individual assets over the network.

Activity icon

Replied to How To Overwrite Cc, Bcc Addresses Of A Mailable Object

This is a risky approach. Better that your .env configures all mail to go to Mailtrap or Helo. You can then see that your To, BCC and CC fields would be correct had the email actually been sent.

Activity icon

Commented on Livewire File Uploads To Amazon S3

Nice to see I turned up in the video! Hopefully we will not need that workaround now with Composer 2.

I run multiple projects under the same AWS account and one of the precautions I take is making sure I have a different IAM user for each project and then restrict that account to the one bucket. If a site is compromised then the attacker does not get access to the other buckets, where you might have backups stored for instance - giving the attacker access to your other sites.

I use an IAM policy like;

{
    "Version": "2012-10-17",
    "Statement": [
    {
        "Effect": "Allow",
        "Action": "*",
        "Resource": [
            "arn:aws:s3:::your-bucket-name",
            "arn:aws:s3:::your-bucket-name/*"
         ],
         "Condition": {}
     } 
     ]
}

add your-bucket-name then the user with this policy cannot access other buckets

Activity icon

Replied to Database Query Being Looped In Blade.

Better if you do it in the database query, within the controller :-)

Activity icon

Replied to How To Implement Reset Password Via Code ?

You are not using any of the regular auth scaffolding? Password reset flow is built into Laravel/UI and Jetstream.

Activity icon

Replied to Trait With Auth::user()->hasRole('x')

Yes, so you are doing it when the scope is applied, not when the trait is booted.

Activity icon

Awarded Best Reply on Demo Email Host

yes, the env file is the config for a specific environment so your local dev continues to use mailtrap, but your production machine has a real mail provider details in its .env file

That way, you don't accidentally mail people whilst developing your code.

Your config/mail.php file gets its values from .env so that you dont end up with environment specific credentials in your codebase

Oct
28
2 days ago
Activity icon

Awarded Best Reply on Reset Password Or Password Verification

This would be considered transactional email

The alternative is bulk mail, ie where every recipient gets the same message.

Think of it like a one to one relationship or a one to many.

Postmark are very good and now offer both forms.

Activity icon

Replied to New Style Update On Laracasts

NO sorry, The abbreviated titles are clever, but awful.

eg

How t... multiple inputs in the same name

... of making a table with millions of rows

Append relationship c... model in Eloquent

all meaning lost!

Activity icon

Replied to How To <br> Split Text If It's More Than A Given Length

but remember to escape the string before you add the <br />

a better strategy is to wrap the contents within a div and the control the width. But I admit, I don't know your use case

Activity icon

Replied to Trait With Auth::user()->hasRole('x')

My guess is that this is the same as doing it in the constructor. When the trait is booted, authentication sessions have not yet started.

This is an old reference, but it discusses the issue

https://laravel.com/docs/5.3/upgrade#5.3-session-in-constructors

Activity icon

Replied to Livewire Wire:click Doesn't Trigger Action Inside Of Foreach

One of the rules of Livewire. Your view must have a single root element that Livewire can base its dom diffing from. Its like setting the scope of the view.

Your code starts and ends with blade tags. These are not really in the view, they are blade macros to create repeating elements, so your view expands out to like;

<div>
	<button.....
</div>
<div>
	<button.....
</div>
<div>
	<button.....
</div>
<div>
	<button.....
</div>

so no single root element

Activity icon

Awarded Best Reply on Livewire Wire:click Doesn't Trigger Action Inside Of Foreach

Your template needs to have a single root element.

<div>
    @forelse($links as $link)
	      <div>
            <button  wire:click="destroy({{$link->id}})"  >Delete Link {{$link->id}}</button>
          </div>
	@empty
		<h2>No Data Found </h2>
    @endforelse
</div>
Activity icon

Replied to Reset Password Or Password Verification

This would be considered transactional email

The alternative is bulk mail, ie where every recipient gets the same message.

Think of it like a one to one relationship or a one to many.

Postmark are very good and now offer both forms.

Activity icon

Replied to Livewire Wire:click Doesn't Trigger Action Inside Of Foreach

Your template needs to have a single root element.

<div>
    @forelse($links as $link)
	      <div>
            <button  wire:click="destroy({{$link->id}})"  >Delete Link {{$link->id}}</button>
          </div>
	@empty
		<h2>No Data Found </h2>
    @endforelse
</div>
Activity icon

Replied to Overriding Eloquent's Create Method Not Working

What if the developer does not use create?

say new MyModel() or MyModel::make() or MyModel::query() or MyModel::createOrUpdate() or MyModel::createOrNew() or firstOrCreate/firstOrNew etc etc

All can be used to create new models, sometimes requiring save(), sometimes not.

And what you are talking about seems to be a side-effect which perhaps ought to be handled through an event or observer.

Food for thought?

Activity icon

Replied to Undefined Variable: Users

@laracoft you are correct.

I was confused with;

DB::table('users')->select('name')

for instance

Activity icon

Replied to Do You Really Like Tailwind And Livewire ?

Looking at a project today for a client. Bootstrap 3 AND a 3000+ line css file with one class per line.

a small sample

.headTxt{float:none;width:100%;margin-top:15px;}
.personnel.resource.cMaterial{background:#57595b;}
.personnel.resource.lab{background:#ce2449;}
.left-course .whatList li.welcome h3{font-size:22px;}
.gdpr-List.newsFeedList li .profileDiv .contentWrp .readB{margin-top:25px;}
.innerService .serv li h2{font-size:24px;width:90%;}
.innerService .serv li .block h4{font-size:22px;}
.emp-Info .imgWrp{display:block;float:none;margin-right:0px;margin-bottom:10px;}
.syllabusList .whatList.moduleList li h3{font-size:22px;}
.syllabusList .whatList.moduleList li h4{font-size:17px;}
.syllabusList .whatList.moduleList li h4{margin-bottom:10px;}
.targetList{width:100%;}
.faqData li{display:block;width:100%;margin-right:0px;margin-bottom:15px;}
.dropdown-content {top:30px;}
.courseData.trainingCourse.landTrain .left-course .course-tab.article-course{min-width:auto;}
.video-Lab.secvideoList .rightLabList.LabListDetails .labList li {width: 32%;}
.video-Lab.secvideoList .rightLabList.LabListDetails .labList li:nth-child(5n){margin-right:1%;}

All I hate about CSS in one file.

Just wondering how I can convince the client to cover the cost of switching to Tailwind (or say bye).

Activity icon

Awarded Best Reply on Undefined Variable: Users

@henrique_f most likely issue is that you are not calling the function you think you are calling, but using the same view?

Do you have this view in another controller method?

The other reason I think this is that your DB statement will not return any data because it is missing ->get()

If you are calling the correct method then put dd($users) in the controller after the database query.

Activity icon

Replied to Undefined Variable: Users

@henrique_f most likely issue is that you are not calling the function you think you are calling, but using the same view?

Do you have this view in another controller method?

The other reason I think this is that your DB statement will not return any data because it is missing ->get()

If you are calling the correct method then put dd($users) in the controller after the database query.

Activity icon

Replied to Overriding Eloquent's Create Method Not Working

Sorry not sure what is happening, but you should use model observers to extend the functionality.

Activity icon

Replied to Livewire Wire:model Update

As suggested ?

Activity icon

Replied to Undefined Variable: Users

You should look more closely at the error message. It will tell you where to find the issue.

Activity icon

Awarded Best Reply on Route Binding Accessing Old Table Name !

its from a validation rule where you have unique or exists rule and have to specify the table name

Activity icon

Replied to Route Binding Accessing Old Table Name !

by the way, never cache config in development (assuming thats where your commands are from) It just causes you to have to remember to clear the cache each time you change anything

Activity icon

Replied to Route Binding Accessing Old Table Name !

its from a validation rule where you have unique or exists rule and have to specify the table name

Activity icon

Awarded Best Reply on Does Laravel Store Assets Outside Public Directory?

Your assets should live in the public folder

Your public folder should be set as the document root

You can tell if your setup is incorrect by looking at page URLs . If you can see public in the URLs then your setup is wrong.

Activity icon

Replied to Demo Email Host

yes, the env file is the config for a specific environment so your local dev continues to use mailtrap, but your production machine has a real mail provider details in its .env file

That way, you don't accidentally mail people whilst developing your code.

Your config/mail.php file gets its values from .env so that you dont end up with environment specific credentials in your codebase

Activity icon

Awarded Best Reply on Little Regex Confusion

preg_match way

Psy Shell v0.10.4 (PHP 7.3.15-1+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> $string = 'The Text I Want [Group One] (Some more)'
=> "The Text I Want [Group One] (Some more)"
>>> preg_match('/(.*)\s\[.*/',$string,$output)
=> 1
>>> $output
=> [
     "The Text I Want [Group One] (Some more)",
     "The Text I Want",
   ]
>>>
Activity icon

Replied to Demo Email Host

You need a provider that will send email on your behalf.

Sometimes your hosting company or domain name registrar will provide this.

If you send a lot of email, you may prefer to use a specialist such as sendgrid, postmark (my preference), Amazon SES, etc etc

Its possible, but I would never recommend it, you can send via a Gmail account.

Its is important that you choose a provider that can give a good sending reputation so that you have good deliverability on your email. The last thing you want is people's password reset links going into spam.

Activity icon

Replied to ErrorException Syntax Error, Unexpected ''); ?>' (T_CONSTANT_ENCAPSED_STRING), Expecting ')' (View: */resources/views/auth/register.blade.php)

I posted my full register.blade.php file

that was my beef. You didn't post the full file because you say the opening tag is there but we don't see it in your question.

Also, all errors come with a stack dump. This shows you the line in the view that caused the issue. If the error is in the component itself then sometimes you might need to back up a bit in the stack to see the error location.

Activity icon

Awarded Best Reply on ErrorException Syntax Error, Unexpected ''); ?>' (T_CONSTANT_ENCAPSED_STRING), Expecting ')' (View: */resources/views/auth/register.blade.php)

OK I see it

<x-jet-label for="citizenship" value="{{ __Citizenship') }}" />

missing opening quote and bracket on the value, should be

<x-jet-label for="citizenship" value="{{ __('Citizenship') }}" />