Haz_

Haz_

Member Since 1 Year Ago

Experience Points
90,030
Total
Experience

4,970 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
782
Lessons
Completed
Best Reply Awards
8
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 19
90,030 XP
Aug
02
2 months ago
Activity icon

Replied to Display String Data In Blade Blade Loop

Ah, I see. Then yes, just do json_decode it? As @thibaultvanc has shown above.

Activity icon

Replied to Display String Data In Blade Blade Loop

Why do you loop through $post with foreach? What do you get when you dd $post->image?

Activity icon

Replied to Display String Data In Blade Blade Loop

@loyd Show us your controller method.

Activity icon

Replied to Display String Data In Blade Blade Loop

@loyd You need to iterate over an array.

 @foreach($post->image as $photo)

This is not an array, unless you have another loop that we aren't seeing?

Activity icon

Replied to Display String Data In Blade Blade Loop

You need to iterate over an array. Example:

Your controller:

$posts = Post::all();

return view('posts.index', compact('posts'));

Your view:

@foreach ($posts as $post)
	{{ $post->caption }}
@endforeach

Edit: Just noticed @thibaultvanc's post above (wasn't there when I wrote ^^), as he said, it's not a valid array. Pass it like I've shown above.

Activity icon

Replied to Laravel Excel Export Model With Relationship

Ah I misunderstood. What happens if you put them inside the first array with mother_name and the rest?

return [
[
 $jobs->I'd
 $jobs->position
 // etc
 $jobs->work,
 $jobs->education
]
]:
Activity icon

Replied to Laravel Excel Export Model With Relationship

You can use the with / withPivot methods. On mobile atm, if I get chance today, I'll update the example.

https://laravel.com/docs/7.x/eloquent-relationships

https://github.com/HazJ/excel-export-demo/tree/master

Aug
01
2 months ago
Activity icon

Replied to Is TDD Worth The Practice?

As I said above, it's well worth $15/mo. The one here by Jeffrey. You can find free resources though. Have a Google.

Laracasts:

https://laracasts.com/series/phpunit-testing-in-laravel

https://laracasts.com/series/code-katas-with-phpunit

Activity icon

Replied to Is TDD Worth The Practice?

There is are a few courses here on Laracasts for TDD. PHPUnit, PEST, Cyprus. You can also find some videos on YT probably for free though I find for 15$, the content, quality and the way it is explained is much better.

Activity icon

Replied to Php Artisan Test Not Passing A Test Case

So it knows to include the test when you run all of them using the command without the flag, else you'll need to specify the test. The annotation basically says, 'hey, include me in the test' when running all.

Jul
31
2 months ago
Activity icon

Awarded Best Reply on Laravel Cors Error

Ah OK. Mark your message ^ as best answer then so it is solved.

Jul
30
2 months ago
Activity icon

Replied to Check The Db To See When Queue Jobs Are Done?

I edited my post above.

Activity icon

Replied to Check The Db To See When Queue Jobs Are Done?

Could you get the returned value of the created Excel file? If creation was a success, send the email. Take a look at this:

https://laravel.com/docs/7.x/queues#job-events

JobProcessed

You're probably going to have to store the successful jobs. Then once all are been run. Perform another to send the emails.

Activity icon

Replied to Laravel Cors Error

Ah OK. Mark your message ^ as best answer then so it is solved.

Activity icon

Replied to Show User Notifications

What do you have so far? Please provide some code. I can't help your render it out on the front end otherwise. I can only assume.

Activity icon

Replied to Laravel Cors Error

Did the link I provided help? If so, mark your question as solved.

Activity icon

Replied to CSS Script Doesn’t Work With .vue

Where do you define your component? How do you call it? You need to compile. You can't just use it like that.

Activity icon

Replied to Fetch Models With Limit On Each Category

You can use the pluck method to achieve this. Combine it with your take method. You could also group them.

https://laravel.com/docs/7.x/collections#method-pluck

Activity icon

Replied to CSS Script Doesn’t Work With .vue

How do you call your Vue component? Have you defined it in the your app.js file as well? Any console errors? Is Vue loading correctly? Further information is needed.

Activity icon

Replied to Maatwebsite/excel BinaryFileResponse Error

As I said, it's going to be really difficult to help you without seeing more of your code base, as that is where the issue lies. If you can simplify a problem down like the example I did, it proves that it is working. The package also works on L6 so it's not that. I'm not sure how else I can help you. Did you even try moving the working example into your project difficult without editing?

Jul
29
2 months ago
Activity icon

Replied to Returning To Model.index View From Controller Update Method Is Adding A URL Parameter

Glad it helped. You are only rendering the view, on the show route as you say.

Activity icon

Awarded Best Reply on Returning To Model.index View From Controller Update Method Is Adding A URL Parameter

You can use named routes.

return redirect()->route('routeName');

Name your route accordingly.

https://laravel.com/docs/7.x/routing#named-routes

Or you can simply do the following:

return redirect('/boilerplate');
Activity icon

Awarded Best Reply on Create Zip With File In Storage Public Disk

You can use basename to achieve this.

    $zip = new ZipArchive;

    if (true === ($zip->open('ReportesTodos.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE))) {
        foreach (Storage::allFiles('public') as $file) {
            $name = basename($file);
            if ($name !== '.gitignore') {
                $zip->addFile(public_path('storage\' . $name), $name);
            }
        }
        $zip->close();
    }

    return response()->download(public_path('ReportesTodos.zip'), 'ReportesTodos.zip');

Hope it helps.

Activity icon

Replied to Returning To Model.index View From Controller Update Method Is Adding A URL Parameter

You can use named routes.

return redirect()->route('routeName');

Name your route accordingly.

https://laravel.com/docs/7.x/routing#named-routes

Or you can simply do the following:

return redirect('/boilerplate');
Activity icon

Replied to Create Zip With File In Storage Public Disk

You can use basename to achieve this.

    $zip = new ZipArchive;

    if (true === ($zip->open('ReportesTodos.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE))) {
        foreach (Storage::allFiles('public') as $file) {
            $name = basename($file);
            if ($name !== '.gitignore') {
                $zip->addFile(public_path('storage\' . $name), $name);
            }
        }
        $zip->close();
    }

    return response()->download(public_path('ReportesTodos.zip'), 'ReportesTodos.zip');

Hope it helps.

Activity icon

Replied to Create Zip With File In Storage Public Disk

I don't understand what you mean. Can you clarify a bit?

If the files are going to be uploaded, you can also just do:

        $zip->addFile(storage_path('app/public/file1.txt'), 'file1.txt');
        $zip->addFile(storage_path('app/public/file2.txt'), 'file2.txt');
        $zip->addFile(storage_path('app/public/file3.txt'), 'file3.txt');

Are you talking about not having a folder in the ZIP called storage?

Activity icon

Replied to Create Zip With File In Storage Public Disk

This:

public_path('storage\file1.txt')

        $zip->addFile(public_path('storage\file1.txt'), 'file1.txt');
        $zip->addFile(public_path('storage\file2.txt'), 'file2.txt');
        $zip->addFile(public_path('storage\file3.txt'), 'file3.txt');

If you use storage_path then it uses the storage folder instead.

https://laravel.com/docs/7.x/helpers#method-storage-path

Make sure the files are located in /storage and that you have linked the storage.

php artisan storage:link

This will make a symbolic link of them in public/storage directory.

Activity icon

Replied to Create Zip With File In Storage Public Disk

What did you do? Create three .txt files as named above. Copy the route and hit it in the browser.

/create-zip

Once this is working, then move it to your controller and modify.

Activity icon

Replied to Create Zip With File In Storage Public Disk

Ah, just noticed you was trying to create it if it didn't exist. Simplify the problem down. This works:

Route::get('/create-zip', function () {
    $zip = new ZipArchive;

    if (true === ($zip->open('test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE))) {
        $zip->addFile(public_path('file1.txt'), 'file1.txt');
        $zip->addFile(public_path('file2.txt'), 'file2.txt');
        $zip->addFile(public_path('file3.txt'), 'file3.txt');
        $zip->close();
        echo 'success';
    } else {
        echo 'error';
    }

    return response()->download(public_path('test.zip'), 'test.zip');
});

I have 3 .txt files named file1, file2 and file3 in my public directory. Slowly build upon it. Have it loop through for a directory to add files manually, etc.

All the info needed was provided.

https://www.php.net/manual/en/ziparchive.addfile.php

https://laravel.com/docs/7.x/filesystem#downloading-files

Hope it helps.

Activity icon

Replied to Create Zip With File In Storage Public Disk

Well you don't upload anything? You also try to open a ZIP that doesn't exist? What are you trying to achieve?

Activity icon

Replied to Create Zip With File In Storage Public Disk

Does the file physically exist in the public folder? Is it inside storage there also? Did you check it? You can also use storage_path instead of public_path as well.

Delete the storage folder and link it again. Then test it.

Activity icon

Replied to Create Zip With File In Storage Public Disk

If you navigate to the file in Explorer, does it exist and if so where is it located? The path.

Try:

asset('storage/ReportesTodos.zip')
Activity icon

Replied to Create Zip With File In Storage Public Disk

Did you create the storage link? Run:

php artisan storage:link

https://laravel.com/docs/7.x/filesystem#the-public-disk

Activity icon

Replied to Maatwebsite/excel BinaryFileResponse Error

Did you try to simplify the problem down? Use a basic controller and export as shown in the example I provided, with a simple route. If that doesn't work then it's must be something in your code base. I would also reinstall the package in case it is corrupt.

Activity icon

Awarded Best Reply on How To Prevent Users To Go To My Login.blade.php After Authentication

Did you try applying middleware to the route as I suggested yesterday?

Route::get('/', function () { return view('auth.login'); })->middleware('guest');

Though it's not ideal. It is most likely going to cause an infinite loop since the redirect route for guest is / by default. You shouldn't really use it on / route. I would change it. I'm also not sure why you are having this issue since as said, Laravel handles this out of the box.

Activity icon

Replied to Maatwebsite/excel BinaryFileResponse Error

I can't help you further then. I've provided a working example. It's something you are doing in your code base. Ask another employee for their help.

Activity icon

Replied to How To Prevent Users To Go To My Login.blade.php After Authentication

Did you try applying middleware to the route as I suggested yesterday?

Route::get('/', function () { return view('auth.login'); })->middleware('guest');

Though it's not ideal. It is most likely going to cause an infinite loop since the redirect route for guest is / by default. You shouldn't really use it on / route. I would change it. I'm also not sure why you are having this issue since as said, Laravel handles this out of the box.

Activity icon

Replied to Maatwebsite/excel BinaryFileResponse Error

Any reason? I'm using the same Excel version as you. L6/L7 both work. Are you able to stick your code on a repo so I can take a closer look?

Activity icon

Replied to How To Prevent Users To Go To My Login.blade.php After Authentication

Are you trying to enforce login across the whole website? Just create a middleware group.

Activity icon

Replied to Maatwebsite/excel BinaryFileResponse Error

Can you update to the latest version?

Jul
28
2 months ago
Activity icon

Awarded Best Reply on Upside Down Image

On mobile atm so can't be much help. I did a quick Google search and found this on SO. Is this relevant to you?

https://stackoverflow.com/questions/50277697/laravel-is-rotating-the-image-when-uploaded

Activity icon

Replied to Resources / Books For Learning MySQL

Once you have mastered the basics. There is a good MySQL database design course here at Laracasts.

https://laracasts.com/series/mysql-database-design