Snapey

at Novate / Microlise

Hire Me

Experience

999,385

1433 Best Reply Awards

  • Member Since 4 Years Ago
  • 958 Lessons Completed
  • 1 Favorite

24th September, 2018

Snapey left a reply on Bugs On Has() • 34 minutes ago

The correct function to use in this case is contains()

$course->lessons->contains('id',$lesson->id);

Snapey left a reply on How To Cache Single Article • 4 hours ago

Your usage seems wrong?

    public function permenentLaw($id)
    {
        return Cache::rememberForever('lawTMD-' . $id, function ()  use ($id) {

            return Law::find($id);
            
        });
    }


Snapey left a reply on Bugs On Has() • 4 hours ago

Thats alright. I have already downvoted you for a question containing no useful information.

Snapey left a reply on Ajax Form Vs Regular Form? • 4 hours ago

Ajax request is supported in all browsers. Version 2 is supported in almost all browsers.

I don't think you have a worry unless forms are being completed on a nintendo wii

https://caniuse.com/#feat=xhr2

Regarding the second question. Do you want contacting by the users if someone says they used the contact form but nothing appeared? If you save in the database, you can build a UI to display all enquiries.

Snapey left a reply on How To Access Files That Uploaded In Storage Directory With Url? • 4 hours ago

the link command creates a symbolic link from the url http://mysite.com/storage into the laravel_project/storage/public folder.

Therefore there is no point in putting images in laravel_project/storage/images because they will not be accessible to the outside world

Snapey left a reply on Laravel Processes My Email Queue But Emails Not Delivered • 10 hours ago

Mailtrap won't care what domain you are sending from, but your smtp server might, or the recipients mail server might.

Check that the values for 'From' and 'To' are valid.

If you are sending the email from yourself, two yourself and using something like gmail, then the email will appear in your sent folder and not your inbox.

I strongly recommend you use a transactional email provider. Read here for more information https://laraveldaily.com/how-to-send-email-from-laravel-and-why-we-need-3rd-party-providers-for-it/

Snapey left a reply on Unable To Find Socket Transport Starttls • 10 hours ago

You have to install the extension, not just uncomment it.

What OS is it?

Snapey left a reply on Ajax Form Vs Regular Form? • 10 hours ago

browser compatibility is good, so I dont think thats an issue.

The main problem is that it is harder to handle well because it relies on frontend skills as well as backend skills.

Its also pointless if after form submission the user is redirected elsewhere anyway.

Snapey left a reply on How To Fetch Relational Data • 10 hours ago

Study Eloquent or have a look at some videos. This is basic stuff

Snapey left a reply on Why UserNotVerifiedException Error Is Not Trigered? • 10 hours ago

@Sergiu17 he is using a package

Snapey left a reply on Bugs On Has() • 11 hours ago

After the millions of uses of the framework, its you, not a bug

23rd September, 2018

Snapey left a reply on Project Ideas • 19 hours ago

This might be a bit boring, but perhaps a tool that you could use yourself.

If you are, or will, freelance, how about an application to keep customer data, the work you do for them and the invoices raised. If services provided have renewals then you could also factor in jobs that check for upcoming renewals and send out emails with pdf attachments. The scope for this can be as much or as little as you want.

One of the first projects I wrote in Laravel was like this, and I still use it today (with some changes along the way).

Snapey left a reply on How Do I Display Only Eloquent Related Data In Blade File • 19 hours ago

remember

But you need to adapt it for the name of your relationship and the name of your category field

You say your categories table has name

then you would need to adapt the query

$healthpackages = healthpackage::whereHas('categories',function($query){
    $query->where('name','popular');
});

but to really help, we would need to see migrations and models, and YOU need to learn how to diagnose if a query returns any data.

For instance, no point in messing about in the view when first step should be to dd($healthpackages);

Snapey left a reply on How Do I Display Only Eloquent Related Data In Blade File • 21 hours ago


$healthpackages = healthpackage::whereHas('categories',function($query){
    $query->where('category','popular');
});

But you need to adapt it for the name of your relationship and the name of your category field

Snapey left a reply on How To Access Files That Uploaded In Storage Directory With Url? • 22 hours ago

have you created the symlink that makes storage/public appear as http://127.0.0.1/storage. ?

Snapey left a reply on Cannot Add Foreign Key Constraint Error 1215 • 1 day ago

I hope it goes without saying that the registrations table must come first in the migrations

Snapey left a reply on LocalStorage With Laravel Not Working • 1 day ago

Answer my question

You have to STOP saying that.

storing something in local storage in the browser has got absolutely nothing to do with any Laravel problem.

Rewrite the question and show code.

Thats as much as Im saying because you are already on my ignore list

22nd September, 2018

Snapey left a reply on Community Submitted Links, Where Are They ? • 1 day ago

whats more embarassing, I even submitted some of them...

Snapey left a reply on Getting Involved • 1 day ago

Getting a bit off topic here. The problem when you start out is that you dont know how to describe the problem, and dont have the vocabulary to know what to search for. This is a big part of why so many topics are repeated and searching so ineffective.

Snapey left a reply on Community Submitted Links, Where Are They ? • 1 day ago

Sorry, they are still here...

https://laracasts.com/community?orderBy=updated_at

but no link visible on the site itself?

Snapey left a reply on How Get Route Name Resource • 1 day ago

Its not possible to name resource routes I think, but clearly there is a way to get the derived name because the command route:list provides it.

maybe Request::is() is what you are looking for?

Snapey left a reply on Publish New Changes After Moderation • 1 day ago

Add an approval datetime column

When the user selects to edit the post, instead of editing the existing post, make a copy of it (minus the approval column)

The approval process will list all posts awaiting approval (where approval is blank) If it is approved then the approval time is filled.

You can then choose if to delete the previous version

When displaying posts you could use a local scope to filter only approved posts.

Snapey left a reply on How Get Route Name Resource • 1 day ago

Sorry, just cannot tell what you are talking about.

Snapey left a reply on Community Submitted Links, Where Are They ? • 1 day ago

there's none here, perhaps you are confused with laravel-news?

https://laravel-news.com/links

Snapey left a reply on Need Suggestion • 1 day ago

you can name fields like patient[1]firstname id you can arrange for an incrementing counter for each patient added

you will then get an array passed to Laravel and can validate with 'patient.*.firstname' etc

Snapey left a reply on Getting Involved • 1 day ago

Theres definately imposter syndrome here as I dont even code for a living ! The only thing I can say, there is no substitute for building stuff and reading stuff.

Participating in the forums has definately improved my skills and of course we do see the same issues coming up over and over again.

Elite ? no way, I've just been around a long time

Snapey left a reply on Eloquent Returning Empty Collection • 2 days ago

Why do you have a create method inside your model?

Why have you created a new base model class with $fillable array? This should be in YOUR individual model

What code returns empty collection?

Snapey left a reply on Send Automation Email From Localhost • 2 days ago

It is but you need a mailserver to relay the email for you.

Try an account at postmarkapp.com (which I use) or mailjet https://www.mailjet.com/pricing/ who have a free tier, 200 messages per day

Snapey left a reply on Google Maps • 2 days ago

If you want to use google maps, and not too familiar with javascript, there is a laravel library that helps a lot

Check this video on Youtube https://youtu.be/LTJ5t3fXoXU

Snapey left a reply on Order By With Relationship • 2 days ago

you should be able to follow the same technique of adding the sorting to the relationship

Snapey left a reply on Order By With Relationship • 2 days ago

If followers are always in the same order, you can add latest() to the relationship

User model

public function followers()
{
    return $this->hasMany(Follower::class)->latest();
}

Snapey left a reply on Checkout With Credit Card Validation In Laravel • 2 days ago

NEVER accept credit card information in your application. It should not touch your server unless you want to deal with PCI compliance.

Anyone can pay with Paypal - you don't need an account (no need to register)

Snapey left a reply on Saving Form Data • 2 days ago

You could use a formRequest and move the validation there.

You cannot do a simple save() of the office location because you have to mess about with the locstatus field, and your locdescription is being filled by loccomment. It would be better if you changed this field on the form.

Request attributes can be accessed directly from the object, you don't need to use input array syntax

So with all that in mind

rename the loccomment to locdescription on your form, then;

public function store(Request $request) {

    $this->validate($request, [
        'locparent' => 'required',
        'locname' => 'required',
        'loccode' => 'required',
        'locdescription' => 'required'
    ]);

    $location = new Officelocation($request->all());

    $location->locstatus = $request->locenabled ? $request->locenabled : 'disabled';

    if($location->save()){
        return back();
    } else {
        
    }
}

Snapey left a reply on How To Pass Collection Data To Blade Component • 2 days ago

You would have a view composer. This would do the initialisation of the $topMenu variable and ensure it is present in every rendered view. Then when your menu is included it will have access to the $topMenu collection and can just iterate over it.

I think you are overthinking it though. There is no need for a component to do this, just an @include on your master layouts.

Components are useful where you want to include the same code on some pages. Things like navigation can usually be part of your master layout.

Snapey left a reply on How To Pass Collection Data To Blade Component • 2 days ago

if your component is the nav bar and not one link, then of course, why not? Where is your doubt?

Snapey left a reply on Database Design • 2 days ago

redis could be the cache store

just write your query as normal then when you are happy, wrap it in the cache helper

You could warm the cache with a job but if the query is not too long just let the first user prime it.

Im guessing it does not need to be exact, eg the leaderboard here on laracasts only updates once per day so your cache duration could be quite long

The final solution really depends on how busy the site is, how much the best sellers move about, and how long it takes to run the query. You dont say how many categories or sales there are.

Snapey left a reply on How To Pass Collection Data To Blade Component • 2 days ago

Have a look at view composers.

Snapey left a reply on Database Design • 2 days ago

It sounds like a job for hasmanythrough which will do a join to get the related model

so Category model has a sales() relationship which is a hasmanythrough using the product table to go from category to product to sales

Then use groupBy and count to workout the sales of product by category.

Definately sounds like a job for caching as well

Snapey left a reply on Section Inside Include • 2 days ago

I dont know if this would ever work, but one consideration is when the parser gets to @yield('style') it does not yet know anything about that section.

Try with the include before the yield, I can't see it working though

Snapey left a reply on Section Inside Include • 2 days ago

there is no point in having section in something that does not @extend

What exactly are you trying to do? Where do you expect this section to be inserted?

Snapey left a reply on Uploading Video Files In Background • 2 days ago

upload it direct to S3 from the client?

Michael Dyrynda has a sequence of blog posts about this

https://dyrynda.com.au/blog/uploading-files-to-amazon-s3-from-the-browser-part-one

21st September, 2018

Snapey left a reply on Required Video Course • 2 days ago

Its commonly called an LMS you might find examples written for other frameworks which could be ported across.

Snapey left a reply on Problem With Register User And Storing Data In Two Tables | Laravel 5.6 • 2 days ago

check your laravel log files. The code could be throwing an error after creating the user.

Snapey left a reply on Unable To Init From Given Binary Data | Intervention | Laravel 5.6 • 2 days ago

Asset helper returns a URL. You don't want a URL when working with files, you want a PATH that the filesystem can understand

try storage_path instead

$img = Image::make(storage_path('assets/images/sample.png'));

adjust your path to suit, I doubt it is storage/app/public/profile/sample.php because thats a php file

Snapey left a reply on Unable To Create Image With Intervention • 3 days ago

@sanjay23 I think that is someone phishing. Its not at all relevant to the question. I have marked it as spam. DONT click on the link.

Most likely problem is that your data has got truncated somewhere

Snapey left a reply on Refering To Public Path • 3 days ago

@viernes You understand the problem right? If you mention localhost in your src= tags then when you want to move it to your hosting, then all your references will be broken.

The correct function, as mentioned here is asset, eg asset('img/photo.jpg');

For this to work, you MUST have the public folder as the Document Root , ie, the root of your website / should be the index.php in your public folder.

Snapey left a reply on AJAX: Can Not Get Data Into Controller • 3 days ago

I sent you a message on twitter

Your browser will send the session key. Is your laptop signed in with the admin account?

Snapey left a reply on AJAX: Can Not Get Data Into Controller • 3 days ago

How do you get a 200 when it does not event hit the controller?

What is the URI seen in dev tools and what routes do you have? Share with me privately if you prefer

Snapey left a reply on AJAX: Can Not Get Data Into Controller • 3 days ago

You need to get comfortable with the browser network tools so that you can see exactly what you are requesting from the server in terms of both the uri + query string and the headers and posted data.

You can then see the servers response also in the network tools.

If you are posting the request and apparently not hitting the controller then either the routing is wrong or some middleware is blocking you.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.