Snapey

at Novate / Microlise

Member Since 5 Years Ago

Mansfield

Experience Points
1,831,575
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
1306
Lessons
Completed
Best Reply Awards
2600
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
1,831,575 XP
Jul
04
1 day ago
Activity icon

Awarded Best Reply on Checkbox Default

    public function store(SectionRequest $request)
    {

	$active = ['active' => $request->has('active') ? 1, 0];

        Section::create($request->except(['_token']) + $active);

        return redirect()->route('section.index')->with(['success' => 'Section created']);
    }
Activity icon

Replied to New Route Isn't Working

run instead php artisan route:clear

When you run optimise, it clears the route cache, then re-caches it. Your routes then cannot be changed until you clear the cache again.

Only use optimise in production.

Activity icon

Replied to Checkbox Default

    public function store(SectionRequest $request)
    {

	$active = ['active' => $request->has('active') ? 1, 0];

        Section::create($request->except(['_token']) + $active);

        return redirect()->route('section.index')->with(['success' => 'Section created']);
    }
Activity icon

Awarded Best Reply on @error Not Working

No, its because you are not causing any validation errors. What in the code you show would return an error?

If login fails, you just return back. This will not contain anything to trigger $error

Activity icon

Replied to Laravel Query Not Returning Correct Information

You would get a lot of mileage from spending a little time learning eloquent

Activity icon

Replied to Symlink() Has Been Disabled For Security Reasons

sorry guys, I am not getting notifications

@niyo

However you are saving your images, just vary the path to be a place that actually exists and does not rely on a symlink

For all those that chimed in with not secure. blah blah. @niyo has not said that these images need to be private, and if you store images in /storage/app/public and then create a symlink then you might as well have just saved them in the public folder in the first place.

@niyo, show how you save these images and I'll show you how to adapt it

Activity icon

Replied to Eloquent And Css

@michaloravec did you mean to say ' you cannot' ?

Jul
03
2 days ago
Activity icon

Replied to How To Handle Failed Login In Laravel

you will need to use javascript on the front end to open the modal if there is a login error

you can pass the error to javascript by putting the open/close status in-line in the javascript using blade tags

Activity icon

Replied to Adding Fields To Validated That Aren't Directly Validated

or

Patient::create($request->validatedExcept('started_at', 'feet', 'inches') + 
    ['height' => ($request->feet * 12)+ $request->inches ]);

and then not use the after validation hook at all

Activity icon

Replied to Adding Fields To Validated That Aren't Directly Validated

You could accept feet and inches into your model as mutators and then create the height during updating and creating model event hooks ?

Jul
02
3 days ago
Activity icon

Replied to How To Prevent From A Table Being Drop In Laravel

I'll repeat. It only fails to drop if the other table contain records point to it. Not if it contains records pointing to that other table.

Referential integrity is to prevent records pointing to thin air. You don't get that unless something is referencing the table being dropped.

Activity icon

Replied to @error Not Working

No, its because you are not causing any validation errors. What in the code you show would return an error?

If login fails, you just return back. This will not contain anything to trigger $error

Activity icon

Replied to @error Not Working

It will only show an error for validation failures.

If you want your failed attempt to also use the validation errors then you could throw a new validation error.

Activity icon

Awarded Best Reply on How To Combine Multiple Queries As One

something like

HrLeaveRequest::query()
    ->selectRaw("status,count(`leave_status`)")
    ->groupBy('leave_status')
    ->where('company_id', $userCompany)
    ->whereYear('created_at', date('Y'))
    ->get()
Activity icon

Replied to How To Combine Multiple Queries As One

Why can't you do that after you get the data

Activity icon

Replied to Problem With Mix Manifest On Shared Hosting

rename public to public_html in your development environment?

Activity icon

Replied to Images Not Showing With Public Url

Don't store the full path in your database. Thats very inflexible, and you definitely don't want the domain name in the database.

Activity icon

Awarded Best Reply on Trying To Get Property Of Non-object With Relation

yes, avoid relationships with the same name as a column

Activity icon

Awarded Best Reply on HasManyThrough The Otherway

just via the middle model?

$article->user->country

assuming article has user relationship and user has country relationship

Jul
01
4 days ago
Activity icon

Awarded Best Reply on How To Handle Views With Nav-link Or Navs And Get A Neat URL?

Route::get('accounts/add', '[email protected]')->name('accounts.add');

It can't be just 'accounts', you already have a route for that

Activity icon

Replied to How To Catch Exceptions When Sending Queued Emails?

rather than queuing the email, queue a job that sends the mail ?

Then in the job's code, you can wrap the mail call in try-catch and report the error rather than letting it bubble up.

Activity icon

Replied to How To Handle Views With Nav-link Or Navs And Get A Neat URL?

Route::get('accounts/add', '[email protected]')->name('accounts.add');

It can't be just 'accounts', you already have a route for that

Activity icon

Replied to Symlink() Has Been Disabled For Security Reasons

Save them instead in a subfolder of public.

Activity icon

Awarded Best Reply on How To Retrieve Address Of All User

You could use whereDoesntHave if you want models that are missing a relation.

You can query using whereHas if you want models that have a particular type of child relation


User::with('address')->whereHas('address',function($query){
	$query->where('country','UK');
})->get();
Activity icon

Replied to How To Combine Multiple Queries As One

something like

HrLeaveRequest::query()
    ->selectRaw("status,count(`leave_status`)")
    ->groupBy('leave_status')
    ->where('company_id', $userCompany)
    ->whereYear('created_at', date('Y'))
    ->get()
Activity icon

Replied to How To Access {{array}} In Laravel ?

Why do you call it {{array}} ?

Activity icon

Replied to How To Prevent From A Table Being Drop In Laravel

@alex_b are you sure?

Surely if it is another table pointing to this one that will prevent it being dropped.

Not if it contains records pointing to another table?

Activity icon

Replied to How To Retrieve Address Of All User

You could use whereDoesntHave if you want models that are missing a relation.

You can query using whereHas if you want models that have a particular type of child relation


User::with('address')->whereHas('address',function($query){
	$query->where('country','UK');
})->get();
Activity icon

Replied to Allowed Memory Size Of 1610612736 Bytes Exhausted (tried To Allocate 4096 Bytes)

I seem to be getting it a lot lately

I run this

php -d memory_limit=-1 /usr/local/bin/composer require league/flysystem-aws-s3-v3

use your own composer command instead of league/flysystem

Activity icon

Replied to How To Retrieve Address Of All User

Why not just query the Address model directly?

Activity icon

Replied to How To Prevent From A Table Being Drop In Laravel

the constraint is not to prevent the table being dropped. Is that what you expected?

Activity icon

Replied to Sessions Regenerate On Every Request With Database Driver

What is your session domain? (.env SESSION_DOMAIN) is it correct?

Activity icon

Replied to HasManyThrough The Otherway

just via the middle model?

$article->user->country

assuming article has user relationship and user has country relationship

Activity icon

Replied to Date Of Modification, In A Specific Field.

Pretty much. Not sure why you need the isDirty check?

Activity icon

Awarded Best Reply on Is It Still Useful To Use ReCaptcha ?

of course, why not. If you don't mind robots creating accounts, you could leave it off?

Activity icon

Replied to Split A Page Into Multiple Pages Using Pagination

Easier if you are ok to put something indicating page break in your post

so if in your post you entered something that represented a page break then you could find it, remove it, and split the post at that point.

eg ==break here==

You just need to look if your editor would wrap this in <div> or <p> and then include that in your search/replace.

Activity icon

Replied to Split A Page Into Multiple Pages Using Pagination

a) The body output in browser is html in paragraph tag and could style it with css

so, your split at 2000 characters could be mid paragraph?

<p>This is my super long article which has <strong>even</strong> some html tags mid paragraph</p>

split might be;

Page 1

<p>This is my super long article which has <strong>ev

Page 2

en</strong> some html tags mid paragraph</p>

so your formatting breaks on both pages. This could be worse if your post contains tables, links etc

Activity icon

Replied to Images Not Showing With Public Url

Could it be that you have a different symlink locally?

Activity icon

Replied to $fillable

It largely depends on whether you have the data in array format to start with.

Typically, you might get a bunch of data from a form, or an imported file, or API and it will be passed to the controller as an array. It can be very convenient to just write that array to the model. The risk is that someone slips in an extra field and changes something they should not.

I go between both techniques quite often - it just depends on the situation.

Activity icon

Replied to Split A Page Into Multiple Pages Using Pagination

a) You don't care about valid html? Your post is only plain text?

b) You don't care about XSS attacks, your post could contain script tags and you just output them RAW to the view?

Activity icon

Replied to How To Prevent From A Table Being Drop In Laravel

yes, so it means that a post record can only be created referencing a valid record in the users table

Activity icon

Replied to $fillable

@Loyd you a) did not understand the question, b) typo'd the property

Mass assignment protection is where you want to pass an array of data and create a model from that for instance with

PageContent::create([])

or

PageContent::update([],[])

if you assign each property individually then call save() then this is NOT mass assignment and does not care about $fillable or $guarded

Activity icon

Awarded Best Reply on Split A Page Into Multiple Pages Using Pagination

Easier if you are ok to put something indicating page break in your post

Then you know where to split it.

Otherwise, you have to read so many characters and then find the next parent element (eg a <div>). Take the first part and count how many characters where in the first part. If you don't split it on a parent element then the html will be broken on page 2

Output the first part to the view

Have a link to part 2, when you get the part 2 route, read the contents again and discard everything up to the previous character count. then repeat incase you need page 3...

Not simple at all.

Activity icon

Replied to Split A Page Into Multiple Pages Using Pagination

Frankly, sometimes I wonder why I bother...

Activity icon

Replied to Problem With Mix Manifest On Shared Hosting

You should be building the assets locally then publishing them

I would not be running npm on the production environment?

Activity icon

Replied to How To Prevent From A Table Being Drop In Laravel

If nothing is referencing it.... ?

Activity icon

Replied to Images Not Showing With Public Url

how are you generating the path for the image in the view?

Activity icon

Replied to Relationship Many To Many Returns 1

can you share your entire product model?