zerodps

zerodps

Member Since 5 Months Ago

Experience Points
13,670
Total
Experience

1,330 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
124
Lessons
Completed
Best Reply Awards
0
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 3
13,670 XP
Nov
27
2 weeks ago
Activity icon

Replied to $donReport Handler Breaks Whole App

sorry ..

        $projects = Image::where('project_id', $id)
        ->join('users', 'users.id_user', 'images.owner_id')
        ->join('projects', 'projects.id', 'images.project_id' )
        ->get();
        
            $html = \View::make('projects.lightbox')
            ->with(compact('projects'))
            ->render();
            return response()->json(['success' => true, 'html' => $html]);

Activity icon

Replied to $donReport Handler Breaks Whole App

Hey guys,

thanks for your help.

The error that is thrown is something i dont want to/can't fix.

local.ERROR: Undefined offset: 0
vendor/laravel/framework/src/Illuminate/Support/Collection.php:2073, ErrorException(code: 0)

It is just an error which wont affect any functionality therefor i want to ignore it at the moment.

How would i ignore those errors with the $dontreport method ?

EDIT

The code which is throwing the error, is just an ajax request which wont fire on only one element on my website

Activity icon

Started a new Conversation $donReport Handler Breaks Whole App

Hey guys,

I tried to add

    protected $dontReport = [
        \vendor\laravel\framework\src\Illuminate\Support\Collection.php
    ];

in my App\Exceptions\Handler.php.

After rebooting, artisan command did not work. In addition to that composer responded with the error

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

Is it just a fundamental error to add Collection.php to $dontReport ?

What am i missing ?

Thanks for your help.

Oct
23
1 month ago
Activity icon

Replied to Validating With Rule::in / Laravel 5.8 MACOS MAMP

Hey @snapey, thank you very much for your help. I really appreciated your support.

I totally forgot about pluck ..

My solution looks like this and works fine for me :

        $user = User::pluck('id_user');
           
 return request()->validate([

                'feature_user_id' => [ Rule::in($user)],

            ]);    
Oct
22
1 month ago
Activity icon

Started a new Conversation Validating With Rule::in / Laravel 5.8 MACOS MAMP

Hi guys,

I'm trying to validate a drop-down menu where my users choose a different username to include in their contribution as a collaborator. However, I send the users ID for verification, like here:

       $id_user = $user->map(function ($user) {
            return collect($user->toArray())
                ->only(['id_user'])
                ->all();
            });

return request()->validate([

featured' => [ Rule::in([$id_user])],
   ]);    

This is failing. I think its failing because the input i try to validate is just the user id (a number) but my Rule checks this

  "id_user" => 4

I looked into mutators but it seems like not useful for my use case. Is there a way to receive only the value from my collection query ?

Thanks in advance !

Oct
16
1 month ago
Activity icon

Replied to Vue With @yield // MAMP MACOS LARAVEL 5.8

NVM found the solution. I fucked up by adding a closing div too much in my yielded view :)

Activity icon

Started a new Conversation Vue With @yield // MAMP MACOS LARAVEL 5.8

Hi guys,

i am currently following the tdd forum tutorial.

I am struggling to find a reason why my template is not rendering the way its supposed to be.

<body>
    <div id="app">
        @include('layouts.nav')
        @yield('content')
        <flash message="{{ session('flash') }}"></flash>

    </div>

<script src="{{ asset('js/app.js') }}"></script>
</body>

Like this, my Flash Component is outside of the

<div id=app> 

and not rendered.

<body>
    <div id="app">
        @include('layouts.nav')
<flash message="{{ session('flash') }}"></flash>
        @yield('content')
        

    </div>

<script src="{{ asset('js/app.js') }}"></script>
</body>

If i put the component before the @yield its actually working.

My Flash.vue

<template>
    <div class="alert alert-warning alert-flash" role="alert" v-show="show">
<strong>Sucess!!</strong>{{ body }}
</div>
</template>

<script>
    export default {
        props: ['message'],
      data() {
          return {
              body: this.message,
              show: false
          }
      }
    };
</script>
 
 <style>
    .alert-flash {
        position: fixed;
        bottom: 25px;
        right: 25px;
    }
 </style>

Any advice is greatly appreciated :)

Thanks

Sep
12
3 months ago
Activity icon

Replied to Type Hint Validation ?

@ftiersch Thank you, that's what I thought. Good to have a confirmation!

Activity icon

Started a new Conversation Type Hint Validation ?

Hi guys,

im trying to advance my security measures in my app. One thing i am not sure about is if i need to validate type hint variables? For example I use to query my database like this:

public function edit($id_user)
{
        $user = User::find($id_user);
}

Is is possible/necesary to validate these inputs?

Thanks in advance !

Sep
04
3 months ago
Activity icon

Replied to Include FIle With Ajax Data ?

I found a solution.

For all those who might be interested in the future.....

I have removed my @include lightbox.blade from the layout because it would be rendered on the server side.

My solution is to append my data with jquery in the actual Ajax request:

$('.content-lightbox-wrapper').append(html['html']);

Hope this makes sense.

Activity icon

Started a new Conversation Include FIle With Ajax Data ?

HI guys,

at the moment I am trying to display a lightbox with more information for the user's project. Due to the high payload of these projects I would like to retrieve the given project information (4k images and videos) via Ajax requests. The Ajax part works fine. My problem is that my lightbox.blade, which is included in my layout file, uses a variable called $projects. This leads to the problem that Laravel shows me the error on every page.

Undefined Variable: Projects

This of course happens because the required data is only sent to the view when the user clicks on the project.

Because I'm still learning, I'm not quite sure if there is a possible workaround. Any help is appreciated!

Thanks in advance

Activity icon

Replied to AJAX In Blade Template

Thanks for your help. @wilk_randall hint worked very well.

My solution looks like this :

  $('.content').click( function(id) {
            var rid = $(this).attr('data-id');

                            $.ajax({
                                // async:false,
                                method: 'GET',
                                dataType: 'json',
                                url: 'image/'+ rid +'  ' ,
                                data: { 
                                },
                                _token: '{{ csrf_token() }}',
                                success: function (projectsjson) {
                                      
                                        if (projectsjson.success) {
                                            $('show_lightbox').html(projectsjson.html);
                                        }
                                    },
                                    error: function (xhr) {
                                        alert('error');
                                    }
                            })
                        })
Sep
03
3 months ago
Activity icon

Started a new Conversation AJAX In Blade Template

Hey everyone,

I'm trying to read some data from an element with an Ajax request. However, I need to find the position of the clicked element, since I'm still very Nooby with Javascript, I'm not sure how to do this. Any help is welcome! My ajax request:

      $('.content').click( function(id) {
                           var loop = $(this).index();
                           console.log(loop);
                            $.ajax({
                                method: 'GET',
                                dataType: 'json',
                                url: 'image/{{$aa['+loop+']->id}}'  ,
                                data: { 
                                },
                                _token: '{{ csrf_token() }}
                            })
                        })

How do i call my var loop inside the ajax request ?

My prior research resulted in this forum post :"https://stackoverflow.com/questions/38585986/search-the-index-of-an-ajax-request-element-in-javascript" but im not quite sure if I need to use the Array.prototype.filter():

Thanks in advance

Aug
23
3 months ago
Activity icon

Replied to Undefined Variable: $loop In @foreach

For anyone who might be interested this is my working update solution:

if(request()->hasFile('image')) {
            foreach(request()->file('image') as $index=>$img) {
                $image = Image::where('images.project_id', '=', $project->id)
                ->get();

        // image upload & save in storage
        $this->validateImage();      
        $extension = $img->getClientOriginalExtension();
        Storage::disk('public')->put($img->getFilename().'.'.$extension, File::get($img));  
        $image[$index]->mime = $img->getClientMimeType();
        $image[$index]->original_filename = $img->getClientOriginalName();
        $image[$index]->filename = $img->getFilename().'.'.$extension;
        $image[$index]->id = $image[$index]->id;
        $image[$index]->save(); 

Again i really appreciate the support of the community

Aug
22
3 months ago
Activity icon

Replied to Undefined Variable: $loop In @foreach

@alkut @cronix

thank you very very much. i really appreciate it.

Activity icon

Replied to Undefined Variable: $loop In @foreach

Hey @alkut this is the basic update function, i thought about splitting the actions in different controllers but it seems that you can only call one controller per form. I think i need to build a service or smth like that...

$project = Project::findorFail($id);
        $project->title = request('title');
        $project->description = request('description');
        $project->save();
        
        if(request()->hasFile('image')) {
            foreach(request()->file('image') as $img) {
                $image = Image::where("images.project_id", "=", $project->id)
                ->get();

        // image upload & save in storage
        $this->validateImage();      
        $extension = $img->getClientOriginalExtension();
        Storage::disk('public')->put($img->getFilename().'.'.$extension, File::get($img));    
     
        $image->mime = $img->getClientMimeType();
        $image->original_filename = $img->getClientOriginalName();
        $image->filename = $img->getFilename().'.'.$extension;
     //   $nextID = DB::table('projects')->max('id') ;
     //   $image->project_id = $nextID;
        
        $image->save(); 
    }

Thanks again

Activity icon

Replied to Undefined Variable: $loop In @foreach

hey @alkut,

i just tried your approach, but i am allready using the foreach loop to iterate the uploaded files so im not quite sure how to implement it.

Is there no workaround to use something like the "$loop" in the controller ?

Aug
21
3 months ago
Activity icon

Replied to Undefined Variable: $loop In @foreach

hey guys,

Thanks guys, I seem to have missed the part about the blade view....

I'm trying to update my existing project, which contains 3 images, all stored in a table, but in a single row. So I thought I'd update my image table with a foreach loop (my knowledge is very limited at this moment and is a learning project :))). Im stuck at :

$image[$loop->index]->save();


As @alkut mentioned: " $img variable is the index now. and explain what you trying to do."

$image[$img->index]->save();

What does this mean can i just use it like $loop ?

$image->save();

This would result in an error because $image is an collection of all three images containing in the project.

I tried to achieve something like an dynamic variable which will increment after the loop has finished.

So it would result in something like this

/* first */
$image[0]->save();
/* second */
$image[1]->save();
/* third */
$image[2]->save();

Thanks again for your time and input !

Activity icon

Started a new Conversation Undefined Variable: $loop In @foreach

Hi guys,

i am trying to iterate some data in my controller like this :

if(request()->hasFile('image')); {
            foreach(request()->file('image') as $img) {
                $image = Image::where("images.project_id", "=", $project->id)
                ->get();
    /* some code */
        
        $image[$loop->index]->save(); 

I keep getting the error

ErrorException (E_NOTICE)
Undefined variable: loop

I could not find any resource in the documentation therefor i ask you guys again :)

Thanks in advance !

Aug
20
3 months ago
Activity icon

Replied to SQL Query With Variable / Laravel 5.6 MacOS

Hey @nakov,

thank you very much for your insight, as i mentioned the ORM topic is not my strongest topic :) I really need to take a closer look at the documentation !

Activity icon

Started a new Conversation SQL Query With Variable / Laravel 5.6 MacOS

Hi all,

Im trying to amend my SQL Query which is working fine to use an variable (or a helper function).

$aa = DB::select('select projects.*, users.*, thumbnails.* from thumbnails inner join projects, users where projects.id = thumbnails.id && users.id_user = projects.user_id');

I would like to use this instead of users.id_user = projects.user_id

$this_user = auth::user()->id_user;

users.id_user = $this_user

Im not really comfortable using Eloquent it is one of my working progresses :)

Thanks for your help !

Activity icon

Replied to Trouble With Authentication / Laravel 5.6 MacOS

@nakov @tykus Hey guys, thank you very much for your input. your suggestions worked like a charm

Activity icon

Started a new Conversation Trouble With Authentication / Laravel 5.6 MacOS

Hi all,

i recently updated my users table primary key (ID),

    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id_user');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

After adding this to my user model everything is working fine

  protected $primaryKey = 'id_user';

The only error im seeing is that the built in laravel authentication is not working properly

$projects = auth::user()->project; 
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'projects.user_id_user' in 'where clause' (SQL: select * from `projects` where `projects`.`user_id_user` = 1 and `projects`.`user_id_user` is not null)

Im quite helpless at this point because im not quite sure how to update the authentication to anticipate my changes. In addition to that I dont really know why SQL is calling 'projects.user_id_user'.

Any help is greatly appreciated. If im missing any information im happy to share.

Thanks

Jul
10
5 months ago
Activity icon

Replied to MergeRecursive() In The Documentation

Thanks for the insight !

Activity icon

Started a new Conversation MergeRecursive() In The Documentation

hi all,

i was wondering if this is a typo. merge recursively also uses the merge() method. I also couldn't find a mergeRecursive() method in Illuminate/Support/Collection.php. So what is the difference between merge and mergeRecursive() ?

mergeRecursive()

The mergeRecursive method merges the given array or collection recursively with the original collection. If a string key in the given items matches a string key in the original collection, then the values for these keys are merged together into an array, and this is done recursively:

$collection = collect(['product_id' => 1, 'price' => 100]);

$merged = $collection->merge(['product_id' => 2, 'price' => 200, 'discount' => false]);

$merged->all();

// ['product_id' => [1, 2], 'price' => [100, 200], 'discount' => false]
Activity icon

Replied to Undefined Offset: 0 / WAMP W10 L5.8.27

fyi

my controller looks like this

        $aa = DB::select('select projects.*, users.*, images.filename, images.project_id from images inner join projects, users where projects.id = images.project_id && users.id = projects.user_id');

my view:

@foreach ($aa as $a)
<div class="content">
    <div class="content-container">
            <img src="{{'storage/' . (($a->filename)) }}"
Jul
08
5 months ago
Activity icon

Replied to Undefined Offset: 0 / WAMP W10 L5.8.27

Hey @mstrauss ,

Thanks for your input !

"Also, does each $project have an image stored at $project['image'][0]->filename?"

Yes and in the future there should be no limit on images within a project. I am reading "https://laravel.com/docs/5.7/eloquent-mutators" at the moment to figure out how i could access the image array dynamicly...

Yeah as @sergiu17 pointed out the error lies in the "[0]". That is why i figured i should call the image array with something like [$id]

Activity icon

Replied to Undefined Offset: 0 / WAMP W10 L5.8.27

Hi Sergiu17,

yeah thats exactly the point i guess. Would you mind show me how to use a "wildcard" when calling in an array ?

Activity icon

Replied to Undefined Offset: 0 / WAMP W10 L5.8.27

So I just saw that i get the error message when using var_dump

var_dump($project['image'][0]->filename)

Could someone explain why dd() would not show this error ?

Activity icon

Started a new Conversation Undefined Offset: 0 / WAMP W10 L5.8.27

Hi all,

im facing a wierd undefinded offset problem.

My Controller

 public function index(Project $project, User $user,Image $image)
    {
        $projects = Project::all();

                
        return view('projects.test', compact('projects'));
    }

my loop

@foreach ($projects as $ $project)
                            <div class="content-container"><img src="{{storage_path() . "\app\public\" . ($project['image'][0]->filename)}}"

the dd is outputting the correct file

@foreach ($projects as $project)
 <?php dd($project['image'][0]->filename) ?>

Trying to view it in the browser will result in the undefined offset error.

Any help is greatly appreciated. BTW if someone could send me any advanced resource about eloquent, i would be super hyped, since it seems the documentation just so covers the basics

Jul
05
5 months ago
Activity icon

Replied to Expected Data Type For GetClientOriginalExtension() / L 5.8.27 WAMP W10

For anyone with the same struggle, this is my solution which is working at the moment :)

public function store(Project $project, User $user,Request $request)
    {
        $attributes = $this->validateProject();
        $attributes['user_id'] = auth()->id();
        
        $img = request()->file('image');
        $this->validateImage();      
        $extension = $img->getClientOriginalExtension();
        Storage::disk('public')->put($img->getFilename().'.'.$extension, File::get($img));
        
        $image = new Image();
        $image->mime = $img->getClientMimeType();
        $image->original_filename = $img->getClientOriginalName();
        $image->filename = $img->getFilename().'.'.$extension;
        $image->project_id = auth()->id();
        $image->save();

        Project::create($attributes);

        return redirect('/projects');
  
    }
Activity icon

Replied to Expected Data Type For GetClientOriginalExtension() / L 5.8.27 WAMP W10

Hey msstrauss,

i have allready tried this. With this approach im back to:

Call to a member function getClientOriginalExtension() on array
Activity icon

Replied to Expected Data Type For GetClientOriginalExtension() / L 5.8.27 WAMP W10

So I tried some different ways but i am unable to find my mistake.

As Snapey mentioned "but when you upload a file, the request contains an instance of the uploaded file object. Only on this object can you call methods like getClientOriginalExtension()"

I have tried to call getClientOriginalExtension with the explicit request but this will end in the error "Call to a member function getClientOriginalExtension() on string" again

Am i missing something here ?

Activity icon

Replied to Expected Data Type For GetClientOriginalExtension() / L 5.8.27 WAMP W10

Hi Snapey,

thanks for your insight. It allready helped me alot !

is this information sufficient ?

     protected function validateImage()
     {
        return request()->validate([
            'image' => ['required']
    ]);    
     }
Activity icon

Started a new Conversation Expected Data Type For GetClientOriginalExtension() / L 5.8.27 WAMP W10

hi all,

sorry for the stupid question, but I couldn't find any information in the documentation.

so this is my code snippet

  $img = $this->validateImage();
        $img['project_id'] = auth()->id();
        $extension = $img->getClientOriginalExtension();
        Storage::disk('public')->put($img->getFilename().'.'.$extension, File::get($img));

This will give me the error

Call to a member function getClientOriginalExtension() on array

My solution was

$extension = $img['image']->getClientOriginalExtension();

Which will give me the error

Call to a member function getClientOriginalExtension() on string

How can i resolve this ?

Activity icon

Replied to Relationship Between Two Loops / Laravel 5.8.26 WAMP W10

Hey, yes sorry didnt thought about this. Unfortunately i didnt found any solution i just changed my approach .. quite new to this site ..

Activity icon

Started a new Conversation Storing Values In Different Tables From A Single Controller Function ? WAMP SQL L5.8.27

Hi all,

I am in the process of brainstorming for my upcoming project... My ideal process would be for the user to submit a single form with some text and an image, in the next step my [email protected] would store the text in a project table and my image references in an image table.

Currently I ignore images, so this is my [email protected], it works fine and my previous approach was to process the image in an additional controller, but I estimated that I wouldn't be able to submit the data in just one form......

$attributes = $this->validateProject();
        $attributes['user_id'] = auth()->id();

        Project::create($attributes);

        return redirect('/projects');

Is this even possible ? Am i overthinking the process ?

Any approach or resource for further education is greatly appreciated !

Thanks in advance,

zero

Activity icon

Replied to How To Rollback Laravel/framework 5.8.27 /WAMP W10

Thanks guys, really appreciate it !

Jul
04
5 months ago
Activity icon

Started a new Conversation How To Rollback Laravel/framework 5.8.27 /WAMP W10

Hi all,

can i rollback a laravel framework update ? If yes, how ?

thanks in advancce

Jul
03
5 months ago
Jun
27
5 months ago
Activity icon

Replied to Test Troubleshooting / WAMP Laravel 5.8.26 W10

@JAYTEE - Oh .. wow thanks for the quick answer and fix.

I really appreciate it!

Activity icon

Started a new Conversation Test Troubleshooting / WAMP Laravel 5.8.26 W10

Hi all,

I am trying to get this test running but phpunit is giving me a error message which leaves me more clueless than before...


Tests\Feature\ManageProjectsTest::a_user_can_create_a_project
Error: Class 'Tests\Feature\Project' not found


the test:


public function a_user_can_create_a_project()
    {
        $this->withoutExceptionHandling();
        $this->signIn();
        $this->get('/projects/create')->assertStatus(200);

        $attributes = [
            'title' => $this->faker->sentence,
            'description' => $this->faker->paragraph   
        ];

        $response = $this->post('/projects', $attributes);
        $response->assertRedirect(Project::where($attributes)->first()->path());

        $this->assertDatabaseHas('projects', $attributes);
        
        $this->get('/projects')->assertSee($attributes['title']);

I am certain that this line is the issue. However I cant explain the reason or any fix for it


     $response->assertRedirect(Project::where($attributes)->first()->path());


Thanks in advance !

Jun
25
5 months ago
Activity icon

Replied to @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

Hey guys,

it's finally working, thank you all so much. I really appreciate it. @snapey @wyatt44 @cronix @fabricecw

much love

Activity icon

Replied to @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

@SNAPEY - so given those two tables :

replies table:


     Schema::create('replies', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('thread_id');
            $table->integer('user_id');
            $table->text('body');
            $table->timestamps();
        });

threads table


Schema::create('threads', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id');
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
    }

Should i change thread_id to bigIncrements or should i change the id to be an intenger ?

Sorry for late reply just came home from work ..

Activity icon

Replied to @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

@CRONIX - hi Cronix,

thanks to you aswell :)

my routes look like that :


Auth::routes();

Route::get('/home', '[email protected]')->name('home');
Route::get('/threads', '[email protected]');
Route::get('/threads/{thread}', '[email protected]');



Activity icon

Replied to @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

@SNAPEY - hi snapey,

thanks for your input !

 public function up()
    {
        Schema::create('replies', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('thread_id');
            $table->integer('user_id');
            $table->text('body');
            $table->timestamps();
        });
    }

I just saw that a few threads have the same thread_id but i cant migrate with thread_id set to bigIncrements

What should be the defintion for thread_id ?

Activity icon

Replied to @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

Hi,

thanks for your input. I really appreciate it. It seems like its empty ...

´´´

Collection {#230 ▼ #items: [] }

´´´

Activity icon

Started a new Conversation @foreach Loop Not Working? Laravel 5.8.24 (WAMP) W10

Hello everybody, I'm working on the series "Let's build a forum with Laravel." In episode 3, Jeffrey displays the thread-related answers with a foreach loop. The problem I have is that the browser does not display HTML elements after my foreach loop. When I comment out the loop and its code, the HTML elements are displayed in the browser.

My threads model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Thread extends Model
{
    public function path()
    {
        return '/threads/' . $this->id;
    }
    
    public function replies()
    {
        return $this->hasMany(Reply::class);
    }
}

My ThreadsController

    public function show(Thread $thread)
    {
        return view('threads.show', compact('thread'));
    }

my show.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{$thread->title}}</div>
                <div class="card-body">
                    {{ $thread->body }}                     
                </div>
            </div>
        </div>
    </div>
    <div class="row justify-content-center">
            @foreach ($thread->replies as $reply)
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">{{ $reply->created_at }}</div>
                    <div class="card-body">
                             
                                     <h4>
                                        {{ $reply->created_at }}   
                                    </h4> 
                                    <div class="body"> {{ $reply->body }} </div>
                           
                    </div>
                </div>
            </div>
            @endforeach
        </div>
</div>   


@endsection


After several hours of trying different approaches, I now hope for your support.

Thanks in advance