Snapey

at Novate / Microlise

Member Since 5 Years Ago

Mansfield

Experience Points
1,670,245
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
1275
Lessons
Completed
Best Reply Awards
2360
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,670,245 XP
Mar
30
12 hours ago
Activity icon

Replied to $appends For A Collection And Avoiding Sticky Relations?

  • Load a set of relationships onto the collection if they are not already eager loaded.

in response to your question

How do I check if relation is already loaded via eager loading (->load() or ->with())

So you can use loadMissing and it will get the model only if it needs to

Activity icon

Replied to BelongsToMany

@jeffreyvanrossum answer is the way to go

Activity icon

Replied to Select All Records Where Due_date = Tomorrow

time does matter.

'Expiring' tomorrow, or 'expired' tommorrow?

Does the field you are checking contain any time value?

Activity icon

Awarded Best Reply on The Best Way To Make Custom HTML Validation Errors In Wordpress ?

better asking somewhere like Stack Overflow

Activity icon

Replied to A Threat Is Showing Without Title And Description

you can see the content in the network tools, but its breaking the rendering somehow

Activity icon

Replied to The Best Way To Make Custom HTML Validation Errors In Wordpress ?

better asking somewhere like Stack Overflow

Activity icon

Replied to Array Paremters In WHERE IN Condition

You might find this one and interesting read;

https://stackoverflow.com/questions/37209686/doctrine-how-to-bind-array-to-the-sql

You can't use prepared statements with arrays simply because sql itself does not support arrays.

Activity icon

Replied to Is My Unique: Validation Rule Set Correctly?

Which unique rule?

do you have columns empid and firstname?

Activity icon

Awarded Best Reply on Display Relation Belong To Many

If you use many to many the belongsToMany is correct

I think you need to swap the third and fourth parameters in each relationship

In addition to customizing the name of the joining table, you may also customize the column names of the keys on the table by passing additional arguments to the belongsToMany method. The third argument is the foreign key name of the model on which you are defining the relationship, while the fourth argument is the foreign key name of the model that you are joining to:

Activity icon

Replied to Form Post Route Laravel Not Found, Laravel 6

Give us the actual error and what you did to cause it.

Activity icon

Replied to Undefined Variable: Users

public function index()
    {
       $users = DB::select('select * from users ')->get();
        return view('index')->with('users' ,$users);
    }

but why use DB

Activity icon

Replied to Display Relation Belong To Many

@hemmy6894 thats a crazy suggestion since there is nothing to pass through. Did you read the thread?

Activity icon

Replied to Send Variables From View (table) To Controller Function

yes, run the query twice, but as @vlatko says, extract it to a common method

Activity icon

Replied to Array Paremters In WHERE IN Condition

also, see Using Named Bindings here

https://laravel.com/docs/7.x/database

as per the SO post I linked earlier

Activity icon

Replied to Array Paremters In WHERE IN Condition

what I am saying is this;

[
        'userId' => $userId,
        ':placesId' => [1,2,3],
        'type' => UserRecentVisits::OBJECT_TYPE_PLACE
    ]);

I've never used named placeholders in raw statement, but you are using two different methods of specifying the parameter, two without colon and one with. Are you sure you need the colon in the parameters? In the query, yes.

Activity icon

Replied to APP_DEBUG On Sharing Host Laravel

you need to look in the server log files for clues. There will normally be a logs folder before you start adding Laravel

Activity icon

Replied to Problem With Laravel 6

sorry, just noticed its an old question

Activity icon

Replied to Problem With Laravel 6

make sure you include the path to the font in a portable way, one that does not require the application to be installed in a specific folder on your c drive.

Show the part of the view where you specify the font

Activity icon

Awarded Best Reply on 404 Error When I Use FormRequest

have you set a header requesting json response. Your validation is probably throwing an error and trying to redirect to the get version of your url, (which does not exist)

Activity icon

Replied to Array Paremters In WHERE IN Condition

so placesId is the only parameter where you preceeded with colon?

Activity icon

Replied to Array Paremters In WHERE IN Condition

You problem is restricted to the use of named placeholders.

Check this thread

https://stackoverflow.com/questions/35960535/laravel-query-builder-parameter-binding/35968797#35968797

but you would be far better (and safer) embracing query builder than sticking to raw queries. It will also give you more readable, expressive queries

Activity icon

Replied to 404 Error When I Use FormRequest

have you set a header requesting json response. Your validation is probably throwing an error and trying to redirect to the get version of your url, (which does not exist)

Mar
29
1 day ago
Activity icon

Replied to Send Variables From View (table) To Controller Function

ajax and hidden forms are NOT the way to go.

You already have all the data in the controller.

create a new route to a method in your controller that performs the same query but saves to a text file instead of sending to a view.

Activity icon

Replied to Issue Str_replace Always Overwrites With A Blank Value

use $thread->save() at the end, not update

Activity icon

Awarded Best Reply on Clean Way Of Handling Error ToString() Must Not Throw An Exception

you do this EVERY TIME you display the user avatar?

validate the users email, do it only when the user saves their profile

wrap the call in a try catch block

Activity icon

Replied to Clean Way Of Handling Error ToString() Must Not Throw An Exception

you do this EVERY TIME you display the user avatar?

validate the users email, do it only when the user saves their profile

wrap the call in a try catch block

Activity icon

Awarded Best Reply on Multiple (multiple Selects) Problem

You need to name each select according to the type so that in the controller you have an array of users for a specific job

Maybe

<select class="select2 form-control" 
    multiple="multiple" 
    name="{{$type->typename}}[]" 
    style="height: 36px; width: 100%;"
>
Activity icon

Replied to Display Relation Belong To Many

please mark this solved

Activity icon

Replied to How Accessor Work?

I think Eloquent gets all values to see if they are dirty (and need saving).

If you gave it a different name, and then use that new name instead, does the problem go away?

Activity icon

Replied to File Upload For 3 Product Images

  1. move your validation to before storing images

  2. change move() to storeAs

  3. you don't handle images on update method?

  4. simplify your code by un-nesting the ifs and extract the common operations to a function

Activity icon

Replied to Only One Display On Relation With Pivot Table

because you get a collection of categories, and then dishes are a collection within each category

Activity icon

Replied to Adding A Color To Cart From Dropdown Menu With Laravel 5.1

your code did not show that.

Check that the request data contains the chosen colour

Activity icon

Replied to Display Relation Belong To Many

If you use many to many the belongsToMany is correct

I think you need to swap the third and fourth parameters in each relationship

In addition to customizing the name of the joining table, you may also customize the column names of the keys on the table by passing additional arguments to the belongsToMany method. The third argument is the foreign key name of the model on which you are defining the relationship, while the fourth argument is the foreign key name of the model that you are joining to:

Activity icon

Replied to Array Paremters In WHERE IN Condition

$raw = DB::SELECT("

            SELECT
               *
              FROM places p
              WHERE p.id IN :placesId
            ",[1,2,3]);

or

$placesId = [1,2,3];

$raw = DB::SELECT("

            SELECT
               *
              FROM places p
              WHERE p.id IN :placesId
            ", $placesId);
Activity icon

Replied to How To Properly Save Image Path?

no, it will not be overwritten. If you don't supply a new image, it returns whatever the value is currently, so no change.

Activity icon

Awarded Best Reply on How To Properly Save Image Path?

does that work? Perhaps findOrFail might be better.

Your save image function looks ok, however it needlessly refetches the person when you have already done that.

It should update the model with the new data but it may be overwritten later.

I would instead, something like this:

$person = $employee->person()->get();
$person->fill($validator->validated());
$person->person_image = $this->storeImage($person);
$person->save();

and then

public function storeImage(Person $person){
    
    if(! request()->has('person_image')){
	return $person->person_image;
    }

    return request()->person_image->store('uploads/'.$person->id, 'public');

}
Activity icon

Replied to How To Properly Save Image Path?

fill is an eloquent model method.

My example is wrong, it should be ->first() not get(). get returns a collection

$person = $employee->person()->first();

Activity icon

Replied to How To Properly Save Image Path?

does that work? Perhaps findOrFail might be better.

Your save image function looks ok, however it needlessly refetches the person when you have already done that.

It should update the model with the new data but it may be overwritten later.

I would instead, something like this:

$person = $employee->person()->get();
$person->fill($validator->validated());
$person->person_image = $this->storeImage($person);
$person->save();

and then

public function storeImage(Person $person){
    
    if(! request()->has('person_image')){
	return $person->person_image;
    }

    return request()->person_image->store('uploads/'.$person->id, 'public');

}
Activity icon

Replied to Adding A Color To Cart From Dropdown Menu With Laravel 5.1

This line

$product_colors = $products->color;

needs to get the color from the request not from the products table.

$product_colors = input::get('product_colors');

or it should reference the id from the product_colors table.

out of interest, why are you doing a project on an unsupported version of Laravel?

Activity icon

Replied to Post Route Is Giving A 500 - Please Help?

amazing. well done you.

Activity icon

Replied to How To Properly Save Image Path?

So, you overwrote person_image on your model with the validated data?

what is $employee?

Activity icon

Replied to Post Route Is Giving A 500 - Please Help?

Then you are probably hitting a route that you dont show.

The error logs will tell you which controller and method you hit.

Remember, in the routes file, they are evaluated from top to bottom

Activity icon

Replied to How To Properly Save Image Path?

looks ok, but we only see part of your code. I would guess somewhere else, after, you are updating Person with request->all()

Activity icon

Replied to Barryvdh/laravel-dompdf Table Page Break Problem

id like to know also. I don't believe so. This means you end up playing safe and leaving a wide margin incase some table lines wrap.

Activity icon

Awarded Best Reply on Barryvdh/laravel-dompdf Table Page Break Problem

the docs say that tables cannot span a page break. You need to close the table before the break, then open a new one.

Activity icon

Replied to Barryvdh/laravel-dompdf Table Page Break Problem

the docs say that tables cannot span a page break. You need to close the table before the break, then open a new one.

Activity icon

Replied to Post Route Is Giving A 500 - Please Help?

Look in the Laravel error logs for the actual cause of the server error

Activity icon

Awarded Best Reply on Carbon Create Instance From Days

Carbon instance must be centered on a date. What date do these intervals relate to?