Snapey

at Novate / Microlise

Member Since 5 Years Ago

Mansfield

Experience Points
1,590,235
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
1232
Lessons
Completed
Best Reply Awards
2249
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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,590,235 XP
Jan
27
10 hours ago
Activity icon

Awarded Best Reply on User Factory

because with this (edited to fix typo)

'user_id'=>auth->id() ?? factory(User::class),

If you are not logged in then you get a complete user model and not just the id

returning it from a closure allows you to grab the ID from the factory created user

Activity icon

Replied to Nesting Selects

eloquent was made for this.

I have no idea if you have models setup with relationships, but I would expect to see something like

$product=Product::with('categories.categories')->find(1);

That categories.categories is where you have a simple category that has child categories

This would give a simple nested result

Activity icon

Awarded Best Reply on Laravel-mpdf Totally Freezing The Port If I Include Image

Sounds like you are you using php artisan serve ?

The built in webserver will only serve one connection at once, so when your script tries to insert an image, it is using a url back to itself. Since it is already serving the pdf code, it cannot get the image and hangs.

The only solution is to run one of the other hosting options such as Valet, xxamp, homestead etc

Activity icon

Replied to When Routes Collide

its about the order of the routes in the file. The routes are evaluated from top to bottom. Put listings before pages and all will be well

Activity icon

Replied to Can I Make With Spatie/laravel-permission Limit Access In Constructor For All Actions?

I don't think you can return anything from constructors. You have to throw an exception.

Try using the abort_unless helper

You also need to put your code inside a middleware callback since the authenticated user is not available when the constructor is first run.

Activity icon

Replied to Laravel-mpdf Totally Freezing The Port If I Include Image

Sounds like you are you using php artisan serve ?

The built in webserver will only serve one connection at once, so when your script tries to insert an image, it is using a url back to itself. Since it is already serving the pdf code, it cannot get the image and hangs.

The only solution is to run one of the other hosting options such as Valet, xxamp, homestead etc

Activity icon

Replied to Nesting Selects

surely categories have subcategories?

Activity icon

Replied to When Routes Collide

please check over your question.It makes no sense.

You dont show any route that would respond to /contact-us and your last paragraph you repeat the same route

Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

next time, check it step by step. Dont just paste in a load of code and expect it to work.

You question was about moving the file to the folder, which is just about the last step. It does not help if you have not proven ANY of the earlier steps

Activity icon

Awarded Best Reply on Add Values On Two Arrays

using collections;

$array1 = collect(['books' => 100, 'pens' => 100, 'rags' => 200, 'eraser' => 300]);

$array2 = collect(['pens' => 50, 'eraser' => 100]);

$result = $array1->map(function($item, $key) use($array2) {
    if($array2->has($key)){
        return $item-$array2[$key];
    }
    return $item;
});
Activity icon

Awarded Best Reply on Unexpected Behaviour In Array Validation

required_ifonly affects the required rule. The other validation rules are still evaluated.

You may need to consider building the array of rules differently depending on the status of your hasOnline input.

Jan
26
1 day ago
Activity icon

Replied to How Do I Override The 404 For The Resource Controller?

please mark best answer. Note that you can replace get() with first(), or firstOrFail()

$code = Code::where('code',$code)->firstOrFail()

then you don't need to check if you get a result as eloquent will throw a not found error

Activity icon

Replied to Creating A Simple Activity Logger

no, no additional table.

When you create a polymorphic relationship, the table can store links relating it to other models. To know which is the other model, eloquent stores a column containing the name of the related model.

Polymorphic relationships can seem scary but they are quite straightforward once you get your head around them

Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

this line

if($file = $request->hasFile('product_image'))

I dont think will give you the file. It will only tell you if request has a file

Surprised you are not seeing errors

Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

is your public folder writable by your web server?

Activity icon

Replied to Laravel Session Not Working

its probably the boot order of service providers meaning you are trying to get session data before it has been prepared.

Nothing whatsoever to do with session lifetime

Activity icon

Replied to Php Artisan Not Working. Tried Almost Everything.

@robertw are you running php artisan in the same folder as the artisan file (the root of your project)

Activity icon

Awarded Best Reply on Form Not Submitting In Remote Server

do you have a folder called booking inside public folder?

Activity icon

Replied to User Factory

because with this (edited to fix typo)

'user_id'=>auth->id() ?? factory(User::class),

If you are not logged in then you get a complete user model and not just the id

returning it from a closure allows you to grab the ID from the factory created user

Activity icon

Replied to Form Not Submitting In Remote Server

do you have a folder called booking inside public folder?

Jan
25
2 days ago
Activity icon

Replied to Getting "Trying To Get Property 'subtotal' Of Non-object" When Using FindOrFail

after this line, is $order set to an instance of order model?

$order = $order_no ? Order::findOrFail($order_no) : $this->createOrder([Order::ORDER_SESSION_ID => $session_id]);

It would help with more of the error message

and change

$order->update();

to

$order->save();
Activity icon

Awarded Best Reply on Redis Jobs Failing Because They're Using Old Code

Are your queues running under supervisor? It has to be stopped and restarted.

Activity icon

Replied to Redis Jobs Failing Because They're Using Old Code

Are your queues running under supervisor? It has to be stopped and restarted.

Activity icon

Awarded Best Reply on Ajax Register New User

    $data = $request->all();

    $data['password'] = Hash::make($data['password']);

    $check = User::insert($data);
Activity icon

Replied to Ajax Register New User

    $data = $request->all();

    $data['password'] = Hash::make($data['password']);

    $check = User::insert($data);
Activity icon

Replied to Role Permission

why are you building something new in such an old version of Laravel?

You just have to work through your requirements piece by piece, experiment, write code, delete it, write it again etc. Ask questions when you have specific problems.

Activity icon

Replied to Open Folder/file In Editor From Page

I looked at the way its done in Ignition, the new error reporter. It allows you to configure for your preferred editor and then open it at the location of the error. Rather than do it from the backend, the editor is launched from your browser. Check the repository https://github.com/facade/ignition/blob/b9081637e856ae55a7c5ff981750696c0d983f3d/resources/js/components/Shared/editorUrl.js#L3

Activity icon

Replied to Open Folder/file In Editor From Page

perhaps with php exec?

Activity icon

Replied to Fetch Data By Date Interval

details matter

01/25/2020 is NOT m-d-Y - it is m/d/Y

Activity icon

Replied to Storing Unknown Data

Depends if you want to hold a 'master record' for a passenger so that you can assign their details to more than one trip.

You will in this case need to make sure you can uniquely identify them so that you don't mix up two John Smith and think they have been on two trips when they are two different people.

And don't forget the principles of GDPR if you are holding personally identifiable information

Activity icon

Replied to Spatie / Laravel-image-optimizer Does't Optimize My Image

Then I guess this package is not suitable for you. Have a look at the optimizers themselves and see if they have been ported to Windows.

Activity icon

Replied to How To Logout Automatically When Session Expired

Session expires on the server. The client does not know it has expired.

Activity icon

Replied to Spatie / Laravel-image-optimizer Does't Optimize My Image

The package will use these optimizers if they are present on your system:

What optimizers do you have installed? You've not mentioned any?

Activity icon

Replied to Laravel Session Not Working

laravel debugbar is a handy tool to have because it shows you what is in session (although in your case you can inspect the database)

So, are records being created and updated in the sessions table?

Jan
24
3 days ago
Activity icon

Replied to I Have Valet Installed, But My Foobar.test Isn't Pinging

A [foobar] symbolic link has been created in [/Users/user/.config/valet/Sites/foobar].

then your site will be available at foobar.test, not project1.test

Activity icon

Replied to Advanced Query With Eloquent, Using Scopes

Get all roles then reject only if they are super admin

$roles =Role:all();

if(Auth::user()->hasRole('Super Admin') {
    $roles->reject(function($role) {
        return $role->name=='Super Admin';
    });
}

No need for else condition

Activity icon

Replied to Advanced Query With Eloquent, Using Scopes

get all roles from database except the one you don't want

Role::where('name','!=','super admin')->get()
Activity icon

Replied to Advanced Query With Eloquent, Using Scopes

get all roles, and reject the Super Admin

Role::all()->reject(function($role) {
    return $role->name=='Super Admin';
});

Activity icon

Replied to Checkbox Save Laracast

create an html form with input fields.

Send form to controller.

Activity icon

Replied to Creating A Simple Activity Logger

You can set the model up using a polymorphic relationship and then Laravel will automatically store the related model name for you.

Activity icon

Replied to Laravel Error During Update - Undefined Variable: Id

You are just updating the one record. In it you need to check that THIS company does not already have that combination of type, value and description?

You cannot do that with this simple unique rule.

You can add additional clauses but not the combination. Does that matter?

Something like;

'rating_type' => Rule::unique('rating_type')->where(function ($query) {
    return $query->where('company_id', $this->rating->company_id);
})->ignore($this->rating);

ignoring the other conditions for this rule.

Activity icon

Replied to Laravel Error During Update - Undefined Variable: Id

Are you sure you want unique on all those columns? So you could not have two different rating_type with the same rating_value?

Anyway, since your route has parameter {rating} you need to use that in the unique rule(s). I'm not understanding though why this would be checked against the company_id column. Does the rating not have an id column?

Activity icon

Replied to Laravel Error During Update - Undefined Variable: Id

Can you show your validation rule now that it has changed.

Also, please run php artisan route:list and show the line relevant to this route.

Activity icon

Awarded Best Reply on Using Str_replace In Blade

does article contain the word 'this' (lowercase) ?

Activity icon

Replied to Laravel Error During Update - Undefined Variable: Id

you can also just write $this->id and laravel will do the magic

its not magic, UpdateRatingsRequest extends Request, so $this is the same as $request

Activity icon

Replied to Where I Can Download Free Icons For Commercial Use

Tailwind resources page is a good one to bookmark https://tailwindcss.com/resources

Activity icon

Replied to Laravel Error During Update - Undefined Variable: Id

because you moved validation to UpdateRatingsRequest where $id does not exist.

In that code, change $id to $this->id

Activity icon

Replied to Using Str_replace In Blade

You could create an accessor on the model and do the work there. (assuming $product is an eloquent model)