Snapey

at Novate / Microlise

Member Since 5 Years Ago

Mansfield

Experience Points
1,836,155
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
2608
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,836,155 XP
Jul
09
5 hours ago
Activity icon

Replied to Validate The Password Reset Token Before Showing The Reset Form

I didn't say it was not possible to brute force the other way, but you are putting extra steps into the process that take time. You can also add Recaptcha or a honeypot to the form.

Anyway, rate limit the requests in some way rather than having an open token validation service.

Jul
08
1 day ago
Activity icon

Replied to Laravel ManyTOMany Eager Loading Where Cond

active departments or active subjects?

What I would do is create a relationship which is scoped

eg, departments model

    public function activeSubjects()
    {
        return $this->hasMany(Subject::class)->where('active',1);
    } 

then eager load

$user->colleges()->with( 'departments.activeSubjects')->paginate(10);

bear in mind that you will need to loop over activeSubjects not subjects

You will get a better response to your questions if you state WHAT error you get

Activity icon

Replied to 404 Not Found

still a problem?

The very first thing you should do is check you get a valid id into the controller since you are using findOrFail

But, you say that the data is saved ? Then the 404 is generated by the show route. You should test this on its own by loading that page on its own, manually entering the id in the address bar

Activity icon

Replied to Detach If Checkbox Is Unchecked

Name the element using the id rather than trying to pass it as a value

	<input
		@foreach($file->product_types as $file_product)
			@if($file_product->id == $product_type->id)
				checked
			@endif
		@endforeach
		type="checkbox" name="product_type[{{$product_type->id}}]"
		value="1">

Now in the controller you will have an array of product_type like

[
 23 => 1,
 45 => 1,
 88 => 1,
]

where 23,45 and 88 are product_type IDs

Now you can loop over the array using the Key as the ID of the product to detach

You also need to alter your check for the checked state since you will have more checkboxes than product_type so you have to look to see if your array of attached models contains the current option.

Activity icon

Replied to Detach If Checkbox Is Unchecked

Why do you have that hidden input there?

Activity icon

Replied to How To Format Min And Max Date In Laravel

Not a Laravel Question. Try this;

<script>
   $(document).ready(function () {
     $('.leaveDate').datetimepicker({
       format: 'MM/DD/YYYY',
       changeYear: false,
       locale: 'en'
    });

     $('.dobDate').datetimepicker({
       format: 'MM/DD/YYYY',
       maxDate:0,
       locale: 'en'
    });

  });

Current year is most easily accomplished by not letting the user change the year

DOB is most easily accomplished as an offset 0 days from today.

Both are theoretical based on reading the API

https://api.jqueryui.com/datepicker/#option-maxDate

Activity icon

Replied to Validate The Password Reset Token Before Showing The Reset Form

@amitshahc

Beware of validating the token before getting any more details from the user. It gives an endpoint that someone can just keep sending random tokens hoping for a match.

They come to your site, with a known user name, trigger password reset then start blasting the route with random tokens. If they get the right one before the account owner knows something is happening then they are in to your site as that user.

Activity icon

Replied to Symlink() Has Been Disabled For Security Reasons

go into the config file filesystems.php and create a new entry below public

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        'upload' => [
            'driver' => 'local',
            'root' => public_path('upload'),
            'url' => env('APP_URL').'/upload',
            'visibility' => 'public',
        ],

Now you have a file system disk called upload which refers to this folder within the public folder (not to be confused with the public disk)

change your controller;

    {
        $this->validate($request, [
            'name' => 'required|min:3',
            'time' => 'required|min:3',
            'description' => 'required|min:10',
            'file' => 'required|file|max:2048'
        ]);

        $path = $request->file('file')->store('/','upload');

        $post = Post::create([
            'name' => $request->name,
            'time' => $request->time,
            'description' => $request->description,
            'file_title' => $upload->getClientOriginalName(),
            'file' => $path,
            'user_id' => Auth::user()->id
        ]);

        return redirect()->route('givePrice', $post->id);
        }

So, now, in your database, you will just have the filename and no path attached. But you know it is in the upload disk.

<img src="{{ asset('upload/' . $post->file }}" >
Activity icon

Awarded Best Reply on Field Doesn't Have Default Value.

With user relation to salesorder, you can instead do

$salesorder = Auth::user()->salesorder()->create($salesorder);
Jul
07
2 days ago
Activity icon

Replied to Field Doesn't Have Default Value.

With user relation to salesorder, you can instead do

$salesorder = Auth::user()->salesorder()->create($salesorder);
Activity icon

Awarded Best Reply on How To Include Several "show" Blades Inside An "index" Blade?

One route, one controller method.

That controller method needs to return all the data needed for the page, or you are into using ajax to 'pull' the data into the page from the client.

Activity icon

Replied to Is A Old Laravel Website Still Safe?

because wordpress updates itself?

Activity icon

Awarded Best Reply on Configuring Database Session Driver

Did you set SESSION_DRIVER in the .env file and then run php artisan config:clear ?

(or remove SESSION_DRIVER from .env)

Activity icon

Replied to With Html2pdf In Generated Pdf As All Css Styles Are Lost

Does html2pdf understand flexbox?

Activity icon

Awarded Best Reply on Is A Old Laravel Website Still Safe?

Are applications written 10 years ago still safe... probably not. Yet at the time, we thought we were using best practices. But still, people discover issues and then exploit those issues on servers that have not been patched.

To think that you can get away with not updating a site for that long is just burying your head in the sand. Besides, we may all be using new devices by then, we will have different design standards, there may be legal requirements regarding all websites for security and accessibility.

The web is a constantly developing thing. Not a book.

Activity icon

Replied to Configuring Database Session Driver

Did you set SESSION_DRIVER in the .env file and then run php artisan config:clear ?

(or remove SESSION_DRIVER from .env)

Activity icon

Replied to Symlink() Has Been Disabled For Security Reasons

Why would you go to all that trouble when you can just save the file to public/images or similar

Jul
06
3 days ago
Activity icon

Replied to Trait Naming Convention

I read this every so often. Nothing there about traits though

https://phptherightway.com/

Activity icon

Replied to Ajax Refresh Duplicates Window

If you are clicking on an anchor , eg <a href="#" then you need to use prevent default to stop the click event causing a page reload.

try

	$('.try').click(function(e){

		e.preventDefault();

		etc

Activity icon

Awarded Best Reply on Soft Delete Return On Show Method

No, you can't do route model binding with soft deleted models.

Activity icon

Replied to Soft Delete Return On Show Method

No, you can't do route model binding with soft deleted models.

Activity icon

Replied to Is A Old Laravel Website Still Safe?

Are applications written 10 years ago still safe... probably not. Yet at the time, we thought we were using best practices. But still, people discover issues and then exploit those issues on servers that have not been patched.

To think that you can get away with not updating a site for that long is just burying your head in the sand. Besides, we may all be using new devices by then, we will have different design standards, there may be legal requirements regarding all websites for security and accessibility.

The web is a constantly developing thing. Not a book.

Activity icon

Replied to Two Checkboxes On The Same Form Don't Work.

right click the bar and make sure method is checked.

There is nothing to choose between them, but feel free to try it in firefox if you have it

Activity icon

Replied to Two Checkboxes On The Same Form Don't Work.

You are looking for a row with a method of POST - assuming your form is actually being submitted

Activity icon

Replied to Laravel: Create A Temporary Session For Guest User And Delete The Session When He Closes The Website Tab

You can put something in the user's session that says they are viewing the alternate menu. When they go away , their session will expire. You cannot force it to expire because you don't know they have gone away.

You can set the session cookie to expire when they close their browser, but that is just a flag on the cookie you send them and they are not forced to close the browser.

Activity icon

Replied to File Uploads Failing On The Server

Could it be that you cannot read from the tmp folder? I've seen some weird issues with people that have the tmp path locked down.

I assume during the upload, you are moving the file from php's temp folder to the final destination.

Activity icon

Replied to Is Anyone Getting Notifications Of Mentions?

@jeffreyway I'm still not getting mentions.

Activity icon

Replied to Two Checkboxes On The Same Form Don't Work.

With the network tab open

Click on the submit button of your form

In the network log, you should see an entry for POST

Click this, then look in the details panel. You are looking for the request. In Chrome click the name of the route in the very first column, you will then get a split screen. Select 'headers' in the new panel. Scroll to the bottom and there you will see Form Data

In Firefox its basically the same process, but the form data is on the Request tab

Activity icon

Replied to Two Checkboxes On The Same Form Don't Work.

I would first look at the browser source and check that both checkboxes are present in the source and have different names, and they are both inside the same form as the submit button

Then I would open the network tab in the developer tools, make a post with both checkboxes clicked and see what is sent to the server in the request.

Activity icon

Replied to How To Include Several "show" Blades Inside An "index" Blade?

One route, one controller method.

That controller method needs to return all the data needed for the page, or you are into using ajax to 'pull' the data into the page from the client.

Activity icon

Replied to What Is The Best Way To Use Same Form For Create And Edit Blade Template In Laravel 6?

@keithmclaughlin

  • makes you forget how to create basic form elements
  • Uses hard to remember parameter passing (was the class the third parameter or the fourth)
  • redundant now that we can easily create components in Laravel 7
Activity icon

Awarded Best Reply on Eager Loading With Single Row

I don't really understand your use case, but;

For instance

$user = UserVerification::find(verification_id)->user()->get(['name','email']);

return $user;

or

$verification = UserVerification::with('user:name,email')->find(verification_id);

return $verification;

Activity icon

Replied to Eager Loading Return Null In Laravel

in tinker,

>>>  DB::connection()->enableQueryLog()

>>> App\Provider::with('currency')->first()

>>> DB::getQueryLog()

Try it also for your working query

Activity icon

Replied to How Can I Get User Information Who Bids On Product?

Does Bidding contain a relationship to User ?

Activity icon

Replied to How Laravel In PHP Imagepng Convert.

ha, good luck with that.

How do you expect the code to be executed when you don't provide a routable URL?

Activity icon

Replied to There Is No Existing Directory At "/home/martin/4evergaming.com/storage/logs" And Its Not Buildable: Permission Denied

it means your webserver does not have permission to write to the storage folder to create the logs directory.

Check your permissions on the storage folder and make sure it is group writable or owned by your web server user (usually www-data)

Activity icon

Replied to Eager Loading With Single Row

I don't really understand your use case, but;

For instance

$user = UserVerification::find(verification_id)->user()->get(['name','email']);

return $user;

or

$verification = UserVerification::with('user:name,email')->find(verification_id);

return $verification;

Activity icon

Awarded Best Reply on 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.

Jul
05
4 days ago
Activity icon

Replied to Column Not Found: 1054 Unknown Column 'comments.conversations_id' In 'where Clause' (SQL: Select * From `comments` Where `comments`.`conversations_id` = 2 And `comments`.`conversations_id` Is Not Null

Please format your code by putting 3 backticks ``` on a line before and after each code block

Assuming your migrations have worked correctly, the comments table should definitely have the conversations_id column

Can you check it is there with your DB admin tool

Activity icon

Replied to Eager Loading With Single Row

or

$user = UserVerification::find(verification_id)->user;

return $user;
Activity icon

Replied to Signed URL To Spécifics Route

This works also, and what I meant

return redirect(signedRoute('projets.draft', ['project' => $project]));
Activity icon

Awarded Best Reply on Signed URL To Spécifics Route

OK we'll start with the basics

At the end of your store method, you should return a redirect, not a url.

I'm assuming you want to go to the new project, but with a signed URL?

            return redirect(signedRoute('projets.draft', ['project' => $project]);
Activity icon

Replied to Signed URL To Spécifics Route

OK we'll start with the basics

At the end of your store method, you should return a redirect, not a url.

I'm assuming you want to go to the new project, but with a signed URL?

            return redirect(signedRoute('projets.draft', ['project' => $project]);
Activity icon

Replied to Signed URL To Spécifics Route

what DO you get?

Activity icon

Replied to Symlink() Has Been Disabled For Security Reasons

no its only the admin and there is no need for bob to view it again

If the admin needs to see the image through the web interface then there is no difference between bob and the admin. The image needs to be stored in a public place if you want to see it through the admin interface.

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

Activity icon

Replied to New Route Isn't Working

ok now ? please mark solved

Jul
04
5 days 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