Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

Rainieren

Experience

8,690

0 Best Reply Awards

  • Member Since 9 Months Ago
  • 49 Lessons Completed
  • 0 Favorites

26th November, 2017

Rainieren started a new conversation Laravel - Delete User With Anchor Tag • 2 weeks ago

Hello, I'm trying to make a function that deletes a user and all their content that they've posted on the website. I want to use an anchor tag for this. Currently, my code looks like this

<td class="text-center">
      <a href="{{ route('deleteUser', ['id' => $user->id]) }}" class="mr-3">
       {{ method_field('DELETE') }}
         <i class="fa fa-trash-o fa-font-24" style="color: red;"></i>
     </a>
     <a href="{{ route('editUsers', ['id' => $user->id]) }}">
         <i class="fa fa-edit fa-font-24" style="color: limegreen;"></i>
     </a>
 </td>

The update anchor tag works just fine but the delete button gives me an error which is:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

I've put a 'dd' in the controller but it does not reach that. What is going on? Can I even use an anchor tag for this?

The route I use looks like this:

Route::delete('/adminpanel/gebruikers/delete/{id}', '[email protected]')->name('deleteUser');

And the controller looks like this:

public function deleteUser($id)
    {
        dd($id);
        $user = User::find($id);

        $user->posts()->delete();
        $user->replies()->delete();

        $user->delete();

        return back()->with('flash', $user->firstname, '`s account is verwijderd.');
    }

Thanks in advance!

25th November, 2017

Rainieren started a new conversation Laravel - Search Through Table By Name & Pagination • 2 weeks ago

I'm making an admin panel and on my users page, I have a table with 53 users. (without pagination). On top of that table, I have an input field which is supposed to act as a search bar. But I don't know how to make it. I want the user to search a username and then the results immediately pop-up without a refresh. So the search needs to be searching by first name.

Are there any good tutorials for this that can help me on my way?

Also, The table has 53 users. How can I paginate the table to show only 25 per page? Because my table currently looks like this: https://imgur.com/a/bOgUn. Thanks in advance!

23rd November, 2017

Rainieren started a new conversation Laravel - Active Status When On Current Page • 2 weeks ago

Hello, I'm trying to add a custom active class to my navbar items if a user is on a specific page. I've tried many things I found on the internet, such as

<li class="nav-item mb-10 {{ Request::path() == '/adminpanel' ? 'class="custom-active"' : '' }}">
     <a class="nav-link text-center " href="{{ route('adminpanel') }}">
       <i class="fa fa-dashboard fa-font-size"></i><br>Dashboard
    </a>
</li>

But for some reason, it just does not work. How can I accomplish this? It also says that request is an undefined class.

Rainieren left a reply on Laravel - Show Latest 5 Registered Users • 2 weeks ago

Nevermind ignore this

Rainieren started a new conversation Laravel - Show Latest 5 Registered Users • 2 weeks ago

I'm trying to make a dashboard and I want to display the last 5 users that are registered on the site, So the most recent 5 registered people. How can I accomplish this? I need to have access to all their attributes, for instance, Name, Lastname etc.

This is my route: Route::get('/adminpanel', '[email protected]')->name('adminpanel');

And this is the controller:

    public function index()
    {
        Carbon::setLocale('nl');
        $tijd = Carbon::today();
        $posts = Post::count();
        $users = User::count();
        $replies = Reply::count();

        return view('admin.dashboard', compact('posts', 'users', 'replies', 'tijd'));

    }

They need to be displayed in a table like this:

    <table class="table table-striped">
     <thead>
      <tr>
       <th>ID</th>
       <th>Name</th>
       <th>Lastname</th>
       <th>Email</th>
     </tr>
     </thead>
    <tbody>
    <tr>
     <th scope="row">1</th>
     <td>Rainier</td>
     <td>Laan</td>
     <td>[email protected]</td>
    </tr>
    </tbody>
    </table>

Thanks in advance

Rainieren started a new conversation Laravel - More Effiecient Way To Count Attributes. • 2 weeks ago

Hello, I have a page where I want to count the number of Posts, Users and comments. But currently, i'm doing it like this. and It looks a bit odd.

public function index()
    {
        $posts = Post::all();
        $users = User::all();
        $comments = Reply::all();

        return view('admin.dashboard')->with('posts', $posts)->with('users', $users)->with('comments', $comments);
    }

Is there a cleaner and better way to accomplish this? Thanks

21st November, 2017

Rainieren started a new conversation Laravel 5.5 - Create Seperate Admin Panel Login Page • 3 weeks ago

Hello, I have an idea, In my project I want people with the role id of 2 to be able to access /adminpanel and log in with their credentials. But only people with the role_ID of 2 can log in. It needs to use the regular user's database. So that the person with the role "admin" can access the admin control panel. What is the best way to achieve this? Are there any sites or tutorials that can help me on my way?

Thanks in advance.

16th November, 2017

Rainieren left a reply on Laravel - POST 422 (Unprocessable Entity) • 3 weeks ago

Okay, I got it working now. But there is one small minor problem which you may know. If a user did not set a profile picture it is supposed to show a placeholder but instead, it doesn't show anything and the URL says /storage/null. I've made a IF statement which does that very thing but somehow it does not work correctly. This is the if statement:

if (! $this->avatar_path) {
            return '/images/avatars/placeholder.png';
        }
        return '/storage/' . $this->avatar_path;

I've put this IF statement in my user model.

Rainieren left a reply on Laravel - POST 422 (Unprocessable Entity) • 3 weeks ago

I never specified it needed to look in a profiel directory, Can you show me an example of what you mean? of for instance, where to specify the full path?

Rainieren left a reply on Laravel - POST 422 (Unprocessable Entity) • 3 weeks ago

Okay, I got it working now, But for some reason, it can't find the photo. It says: GET http://ict-hulp.dev/profiel/avatars/BvmDnLQg95a1Ocg3wdWoqj2GMSYPlQZqS6XMYLPb.jpeg 404 (Not Found)

I don't get it because the URL is correct, look: https://imgur.com/a/eMH4C And it filled the image source: https://imgur.com/a/QAzPT

It also doesn't show the placeholder if I haven't selected an image. Which is should

Rainieren left a reply on Laravel - POST 422 (Unprocessable Entity) • 3 weeks ago

The error it gives is:

{message: "The given data was invalid.", errors: {avatar: ["The avatar must be an image."]}}
errors
:
{avatar: ["The avatar must be an image."]}
avatar
:
["The avatar must be an image."]
message
:
"The given data was invalid."

I don't get it, I uploaded an image but it says it is invalid. I added this to my input file, Maybe this has something to do with it?

<input type="file" name="avatar" accept="image/*" @change="onChange">

Thanks for helping!

Rainieren started a new conversation Laravel - POST 422 (Unprocessable Entity) • 3 weeks ago

Hello, I have a small problem, I followed Jeffrey's tutorial on how to ajaxify the image upload system for a users profile, but I have an error on uploading a file. It for some reason says.

POST http://ict-hulp.dev/gebruikers/Rainieren/avatar 422 (Unprocessable Entity)

I don't know where this problem occurs but if I comment out this line of code in my avatarForm.vue:

axios.post(/gebruikers/${this.user.username}/avatar, data).then(() => flash('Foto bewerkt!'));

It does not give me an error at all. The route does exist. You can see it in this picture: https://imgur.com/a/f3uqv

Where can I look for the problem? This is a list of the files used in this problem:

AvatarForm.vue: https://pastebin.com/RUk11rb8

[email protected]: https://pastebin.com/NcjT1m4y

ImageUpload.vue: https://pastebin.com/vswYqgiU

Thanks in advance

15th November, 2017

Rainieren left a reply on Laravel - Connection Could Not Be Established With Host • 4 weeks ago

It did. So I think it is myy provider then, let me try gmail

Rainieren left a reply on Laravel - Connection Could Not Be Established With Host • 4 weeks ago

@rob897 I don't know if my hosting provider is blocking the port, It says on their site that it needs verification, but I guess that's what SSL does, But I, of course, can be wrong.

I honestly don't quite know if I have access to the server, and Honestly, dont understand what telnet does or where to put it the code, Can you maybe be more specific?

Rainieren started a new conversation Laravel - Connection Could Not Be Established With Host • 4 weeks ago

Hello, I made a mail register system, Where if a user registers their account, an email will be sent and they can confirm their account. The problem is, If I try to send emails from my host which is 'smtp.ziggo.nl'. It displays this: https://imgur.com/a/BnFtU I've put all my information into the mail.php file and edited my .env file to this https://imgur.com/a/OZYSz

What am I doing wrong? And where can I look for the problem?

thanks in advance!

13th November, 2017

Rainieren left a reply on Laravel - Unexpected Token } • 1 month ago

It is solver already, I'm sorry, If only you could delete posts. Thanks for trying to help though

Rainieren started a new conversation Laravel - Unexpected Token } • 1 month ago

Hello Again, I'm following Jeffrey's tutorial, Episode 36 and I ran into a problem AGAIN which I can't solve. This is a weird error and the longest error code I've ever seen, Anyway, the error is in this picture: https://imgur.com/a/annjq

The problem is, Now my whole post page does not show. And the thing is. If I uncomment this

@if(Auth::user()->id == $post->user_id)
                            <form action="{{ $post->path() }}" method="POST">
                                {{ csrf_field() }}
                                {{ method_field('DELETE') }}

                                <button type="submit" class="btn btn-link p-0">Verwijder post</button>
                            </form>
                            @else

                            @endif

from my show.blade file it gives me the error: Trying to get property of non-object I did not do anything. Everything worked fine and suddenly this happened. I don't know where to look for the problem but I bet it has something to do with the replies. this Occured when I was following the tutorial from 14:21 to 14:54. I'm absolutely horrible at problem solving. I'm sorry for asking so many questions.

Thanks in advance

Rainieren left a reply on Laravel - VueJS Cannot Read Property 'username' • 1 month ago

Thanks you so much! You are a hero! I can finally move on! The code worked, Thanks

Rainieren left a reply on Laravel - VueJS Cannot Read Property 'username' • 1 month ago

Here is my ReplyController: https://pastebin.com/p41uCDvZ. I'm just trying to show the replies, and I'm not trying to run a method, Anyway, Here is the Reply model: https://pastebin.com/yUGsX258 I hope its somewhere in there.

Sorry for using Pastebin, I want to avoid placing these big chunks of code in my posts, And I think it looks better this way.

Rainieren left a reply on Laravel - VueJS Cannot Read Property 'username' • 1 month ago

I think I do, I followed every step of the tutorial. If I look in the console under the Vue tab, I can see the props which have the post and the user id's, How can I check if I send an owner back?

Rainieren left a reply on Laravel - VueJS Cannot Read Property 'username' • 1 month ago

@Lars-Janssen If I make a created() property and add alert(data.owner) to it it says data is undefined but If I remove that property is just telling me that username is undefined, If I add console.log(data.owner); into the console it tells me that data is undefined. Whats going on?

Rainieren started a new conversation Laravel - VueJS Cannot Read Property 'username' • 1 month ago

Hello, I'm following Jeffreys forum tutorial, and I'm currently in episode 36. I followed the tutorial from 0:00 till 7:20, and at that moment there is a brief second where he switches to the page to see the replies. The problem is, I don't see my replies at all. Instead, I get an error in the console, The error is stating:

[Vue warn]: Error in render: "TypeError: Cannot read property 'username' of undefined"

found in

---> <Reply> at resources\assets\js\components\Reply.vue
       <Replies> at resources\assets\js\components\Replies.vue
         <PostView> at resources\assets\js\pages\Post.vue 

I don't know what is causing this, and I have been stuck with this problem for more than a day now. I did some digging to look if I even had the owner method in my Reply model and I do. So why can't it fetch the reply's owner's username?

For the sake of keeping this question short, I've created some Pastebin links to the files that are maybe causing the problem

Reply.vue: https://pastebin.com/sGNgkgy3 Post.vue: https://pastebin.com/H9sjcZij Replies.vue: https://pastebin.com/LiKUapyn

Thanks in advance

Rainieren left a reply on Laravel - VueJS Replies Not Displaying • 1 month ago

It gives me this error in the console: https://imgur.com/a/xZU4y

It can't find the username of the owner of the reply. I've changed data.user.username to reply.user.username to see if that changes anything but it does not. Any suggestions?

Rainieren left a reply on Laravel - VueJS Replies Not Displaying • 1 month ago

@robrogers3 I know the problem. In my Reply.vue I am tryking to get the link to a users profile page. I try to get the username like this:

<!--<a :href="'/profiel/'+data.user.username" v-text="data.user.username"></a>zei {{ data.created_at }}...-->

But it gives me an error in the console that the value username does not exist. When I remove it the replies show just fine. Do you have any idea how to solve this? These are the files connected to it,

Reply.vue

<template>
    <div :id="'reply-'+id" class="card mb-3">
        <div class="card-header">
            <div class="card-title mb-0">
                <!--<a :href="'/profiel/'+data.user.username" v-text="data.user.username"></a>zei {{ data.created_at }}...-->
            </div>
        </div>
        <div class="card-body">
            <div v-if="bewerken">
                <div class="form-group">
                    <textarea class="form-control" v-model="text" required></textarea>
                </div>

                <button class="btn btn-sm btn-primary" @click="update">Bewerken</button>
                <button class="btn btn-sm btn-link" @click="bewerken = false">Sluiten</button>
            </div>
            <div v-else v-text="text"></div>
        </div>
        <div class="card-footer level">
        </div>
    </div>
</template>
<script>
    export default {

        props: ['data'],

        data() {
            return {
                bewerken: false,
                id: this.data.id,
                text: this.data.text
            };
        },

        methods: {
            update() {
                axios.patch('/replies/' + this.data.id, {
                    text: this.text
                });

                this.bewerken = false;

                flash('Je reactie is bewerkt!');
            },

            destroy() {
                axios.delete('/replies/' + this.data.id);

                this.$emit('Verwijderd', this.data.id);


            }
        }
    }
</script>

Post,vue

<script>

    import Replies from '../components/Replies.vue';

    export default {
        components: { Replies }
    }
</script>

and Replies.vue

<template>
    <div class="card">
        <div v-for="(reply, index) in items">
            <reply :data="reply" @deleted="remove(index)"></reply>
        </div>
    </div>
</template>

<script>

    import Reply from './Reply.vue';

    export default {
        props: ['data'],

        components: { Reply },

        data() {
            return {
                items: this.data
            }
        },

        methods: {
            remove(index) {
                this.items.splice(index, 1);

                flash('Reactie is verwijderd')
            }
        }
    }
</script>

Sorry for the long post, Thanks

Rainieren left a reply on Laravel - VueJS Replies Not Displaying • 1 month ago

@robrogers3 On the post page I only see the post itself without the replies. My Vue console looks like this: https://imgur.com/a/XqgAF

The weird thing is. In the console, I can see that it loops all the replies but they are empty, Look: https://imgur.com/a/oLUp5

Here are the 3 files that are required for this, Sorry for the long post.

Post.vue

<script>

    import Replies from '../components/Replies.vue';

    export default {
        components: { Replies }
    }
</script>

Replies.vue

<template>
    <div>
        <div v-for="(reply, index) in items">
            <reply :data="reply" @deleted="remove(index)"></reply>
        </div>
    </div>
</template>

<script>

    import Reply from './Reply.vue';

    export default {
        props: ['data'],

        components: { Reply },

        data() {
            return {
                items: this.data
            }
        },

        methods: {
            remove(index) {
                this.items.splice(index, 1);

                flash('Reactie is verwijderd')
            }
        }
    }
</script>

Reply.vue

<template>
    <div :id="'reply-'+id" class="card mb-3">
        <div class="card-header">
            <div class="card-title mb-0">
                <a :href="'/profiel/'+data.user.name" v-text="data.user.username"></a>zei {{ data.created_at }}...
            </div>
        </div>
        <div class="card-body">
            <div v-if="bewerken">
                <div class="form-group">
                    <textarea class="form-control" v-model="text" required></textarea>
                </div>

                <button class="btn btn-sm btn-primary" @click="update">Bewerken</button>
                <button class="btn btn-sm btn-link" @click="bewerken = false">Sluiten</button>
            </div>
            <div v-else v-text="text"></div>
        </div>
        <div class="card-footer level">
            <!--<form method="POST" action="/replies/{{ $reply->id }}/likes">-->
                <!--{{ csrf_field() }}-->
                <!--<button type="submit" class="btn btn-theme btn-hover" {{ $reply->isLiked() ? 'disabled' : '' }}>-->
                    <!--<i class="fa fa-thumbs-o-up"></i> {{ $reply->likes()->count() }}-->
                <!--</button>-->
            <!--</form>-->

            <[email protected]('update', $reply)-->
                <!--<button class="btn btn-sm btn-secondary ml-2" @click="bewerken = true">Bewerk</button>-->
                <!--<button class="btn btn-sm btn-danger ml-2" @click="destroy">Verwijder</button>-->
            <[email protected]>
        </div>
    </div>
</template>

<script>
    export default {

        props: ['data'],

        data() {
            return {
                bewerken: false,
                id: this.data.id,
                text: this.data.text
            };
        },

        methods: {
            update() {
                axios.patch('/replies/' + this.data.id, {
                    text: this.text
                });

                this.bewerken = false;

                flash('Je reactie is bewerkt!');
            },

            destroy() {
                axios.delete('/replies/' + this.data.id);

                this.$emit('Verwijderd', this.data.id);
//                $(this.$el).fadeOut(300, () => {
//                    flash('Je reactie is verwijderd!');
//                });


            }
        }
    }
</script>

Thanks,

12th November, 2017

Rainieren started a new conversation Laravel - VueJS Replies Not Displaying • 1 month ago

I have a problem where I have been stuck with for a long time, I've tried asking it on Laracasts and even on StackOverflow, but I just can't find the answer. I'm currently following the forum tutorial from Jeffrey, and I am in Episode 36. At 7:20 I was starting to get worried, He switched briefly to his post page where you could see the replies. I have a problem where I do not see the replies at all!

When I open the console and go to the Vue tab is all shows up correctly in the console, The replies just don't display. I did some digging to find what the problem could be and after a whole day of searching I think I have found the problem, but I'm not too sure.

In the pages/Post.Vue file he specified the path to Replies.Vue which is what I think is supposed to display all the replies, My PHPStorm tells me that the path is correct, But somehow the replies just don't display.

I'm honestly getting really desperate to get this solved because I don't know where to look anymore.

Here is a picture of the Post file where he specifies the path

File: https://imgur.com/a/CbHqQ

Rainieren started a new conversation Laravel - VueJS Problems. • 1 month ago

Hello, I've been struggeling with Vue for the past 6 hours. The whole experience has been horrible, and It never goes seamlessly. I'm following Jeffreys tutorial on how to make a forum, and currently, I'm watching episode 36. I followed every step he took four times! Until 7:20 where he switches to the page and sees all the replies. The problem here is, I don't see anything at all. And for some weird reason, The Vue devtool tells me Vue isn't even detected on the page anymore. And I didn't do anything. He also made the post itself a Vue component, but that shows just fine...

I'm getting desperate to get vueJS working without any problems. It does not matter how many times I clear my cache or hard reload, The issues keep occurring The errors I get in my console is this: https://imgur.com/a/0AE1I

Did anyone else have this sort of experience with VueJS? How can I fix this because it's driving me nuts! I'm not going to post all my files in this question just for the sake of keeping this post short, If they are needed, Please say so

Thanks in advance!

Rainieren left a reply on Laravel -VueJS Not Working • 1 month ago

I fixed it, It was a problem with the placement of the element where VueJS can be used. I'm sorry, Thanks for the help though!

Rainieren left a reply on Laravel -VueJS Component Not Working • 1 month ago

@marthz Okay, The error is supposed to appear on the console. The thing is. I didn't do anything and now if I hard-code some text into that flash message, after a long while of refreshing it appears.

When I add the non-existent reply component to my reply.blade.php it SHOULD remove all my replies from my blade, and it is supposed to give me this error that the component does not exist. Instead, it doesn't do anything like that. This is the error it is supposed to provide: https://imgur.com/a/2CXls.

I've tried compiling it multiple times with npm run dev and npm run watch but none of that works

If I delete my node_modules folder. Do I have to install every dependency that is in my package.json again?

Rainieren left a reply on Laravel -VueJS Component Not Working • 1 month ago

@marthz Yes, it is, The weird thing is, My devtools work. And it says vueJS is detected on the page. But whenever I try to do something with Vue it just doesn't work. I've been attempting clearing cache and hard-refreshing, but none of that works. It doesn't do anything even If I hard code some text into my flash message it just doesn't show. The weird thing is, The Vue flash message I have still displayed. But whenever I make changes to it like for instance, adding text, it doesn't show. What is causing this?

Rainieren started a new conversation Laravel -VueJS Component Not Working • 1 month ago

Hello, I'm following Jeffrey's tutorial on how to edit a reply with Vue.

When he adds the non-existent reply tag, it gives him an error in the console and removes all the replies, But when I do the same it doesn't do anything at all, It still shows all the replies and it does not give me an error message, What is causing this? The blade file looks like this:

  <div class="row">
                <div class="col-md-9">
                    @foreach ($post->replies as $reply)
                        <reply inline-template> //Reply component is here
                            <div class="card mb-3">
                                <div class="card-header">
                                    <div class="card-title"><a href="">{{ $reply->owner->username }}</a> zei {{ $reply->created_at->diffForHumans() }}...</div>
                                </div>
                                <div class="card-body">
                                    {!! $reply->text !!}
                                </div>
                                <div class="card-footer level">

                                    <form method="POST" action="/replies/{{ $reply->id }}/likes">
                                        {{ csrf_field() }}
                                        <button type="submit" class="btn btn-theme btn-hover" {{ $reply->isLiked() ? 'disabled' : '' }}>
                                            <i class="fa fa-thumbs-o-up"></i> {{ $reply->likes()->count() }}
                                        </button>
                                    </form>

                                    @can('update', $reply)
                                        <form method="POST" action="/replies/{{ $reply->id }}">
                                            {{ csrf_field() }}
                                            {{ method_field('DELETE') }}
                                            <button type="submit" class="btn btn-sm btn-danger ml-2">Verwijder</button>
                                        </form>
                                    @endcan
                                    <button class="btn btn-sm btn-secondary ml-2" @click="bewerken = true">Bewerk</button>
                                </div>
                            </div>
                        </reply>
                    @endforeach
                </div>
            </div>

If I'm correct, and the reply component does not exist it shouldn't show all the replies, and it should give me an error stating that the component does not exist but it doesn't do any of that.

Thanks in advance

11th November, 2017

Rainieren started a new conversation Laravel - VueJS Adding Transitions To Flash Message • 1 month ago

Hello, I've followed Jeffrey's tutorial on how to add flash messages and I was wondering how to add an effect to it, I've stumbled across this https://vuejs.org/v2/guide/transitions.html But how can I add it in the code he wrote? I want to use the slide-fade effect How can I add it to the flash message? For clarity: Here is the Flash.vue code:

<template>
    <div class="alert alert-success alert-style"  role="alert" v-show="show">
        <strong>Succesvol!</strong> {{ bericht_body }}
    </div>
</template>

<script>
    export default {

        props: ['bericht'],

        data() {
           return {
               bericht_body: '',
               show: false
           }
        },

        created() {
            if (this.bericht) {
                this.flash(this.bericht);
            }

            window.events.$on('flash', bericht => this.flash(bericht));
        },

        methods: {
            flash(bericht) {
                this.bericht_body = bericht;
                this.show = true;

                this.hide();
            },

            hide() {
                setTimeout(() => {
                    this.show = false;
                }, 3000);
            }
        }
    }
</script>


<style>
    .alert-style {
        position: fixed;
        right: 25px;
        bottom: 25px;
    }

    .slide-fade-enter-active {
        transition: all .3s ease;
    }
    .slide-fade-leave-active {
        transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
    }
    .slide-fade-enter, .slide-fade-leave-to
        /* .slide-fade-leave-active below version 2.1.8 */ {
        transform: translateX(10px);
        opacity: 0;
    }

</style>

Rainieren left a reply on Laravel - Route Not Accesable • 1 month ago

Currently nothing, But If I do /vragen/create in my web browser I should see the DD right?

Rainieren started a new conversation Laravel - Route Not Accesable • 1 month ago

Hello, I've come across something pretty weird. I made a route inside my web.php named Route::post('/vragen/create', '[email protected]'); which is supposed to store a new post. But whenever I try to access that route, it tells me the page non-existent. My PostController's store method looks like this:

public function store(Request $request) {

    dd($request->all());


    return redirect($post->path());
}

If have DD'd the method to see what will return but I can't even access that. What is causing this?, Because I can't create posts this way, If I try to make a post I get the error 'No Message' instead of the DD I am supposed to get returned. What is causing this?

This is my whole routes file

Route::get('/', '[email protected]')->name('home');
Route::get('/vragen', '[email protected]')->name('showQuestions');
Route::post('/vragen/create', '[email protected]');
Route::get('/vragen/{channel}', '[email protected]');
Route::get('/vragen/{channel}/{post}', '[email protected]');
Route::post('/vragen/{channel}/{post}/replies', '[email protected]')->name('addReply');
Route::post('/replies/{reply}/likes', '[email protected]');

Route::get('/aanbieders', '[email protected]')->name('showCompanies');
Route::get('/aanbieders/{channel}/{CompanyPost}', '[email protected]');

Route::get('logout', function() {
    Auth::logout();
    return redirect('/');
});

Auth::routes();

Rainieren started a new conversation Laravel - Give Specific Names In Database Specific Colours In Blade • 1 month ago

Hello, I followed Jeffrey's tutorial, and I want to make use of the channel concept as well. But I'm trying to figure out how I can give specific channel names specific colours, say, For instance, the channel with the name "Plants" needs to be green while the channel with the name "Fire" needs to be red. How can I accomplish this the most efficient way? I display my channel names in blade using `{{ $post->channel->channel_name }}. Thanks in advance!

Rainieren left a reply on Laravel - Post Owner Not Displaying • 1 month ago

I'm so sorry, Its almost embarrassing to say but I've made a typo, I typed name but instead I mean to say first name. I'm sorry, Thanks for trying to help though!

Rainieren left a reply on Laravel - Post Owner Not Displaying • 1 month ago

I've set my database up like all my previous projects and I've got no problems there, I don't think it is in my database, I use PHPMyAdmin if you're wondering.

I always set my database up using migrations, If u are interested in seeing those they're below, Just to keep this post short I have made 3 images. You can check these out here:

create_users_table: https://imgur.com/a/95Hkt create_posts_table: https://imgur.com/a/dHFRO create_replies_table: https://imgur.com/a/yka0N

I don't know where to look, This is the information I can give to you. If u need anything more. Please tell me, Thanks for trying to help!

Rainieren left a reply on Laravel - Post Owner Not Displaying • 1 month ago

Nope, I've tried that, The one App/User gives me the error stated above, And the other App\User one doesn't give me an error at all and doesn't display the name either. Currently, I have them in the state that it doesn't give me an error at all and doesn't show the name either. I've done composed dump-autoload again, but it doesn't change anything. Any suggestions?

Rainieren left a reply on Laravel - Post Owner Not Displaying • 1 month ago

@MorganRowse I've followed your steps, Both of those files are in that directory, Both those files have namespace App; And there are no imports in both the files at all except use Illuminate\Database\Eloquent\Model; After I checked all that I've done composer dump-autoload And I changed all my models from User:: class to App/User Like I've done with my previous project. But STILL, i get the same error. What is causing this? It's driving me nuts...

Rainieren left a reply on Laravel - Post Owner Not Displaying • 1 month ago

Yeah I thought if I should've put that in the question but I've tried that already, It gives me the error Class 'App/User' not found (View: C:\xampp\htdocs\laravel\ICT-Hulp\resources\views\posts\show.blade.php) And those two relations are not the problem, It should display the user either way, But I've removed one to see if it works but no, It still does not display the user, and It still does not give me an error message, Have any other suggestion?

Rainieren started a new conversation Laravel - Post Owner Not Displaying • 1 month ago

Hello, I'm following Jeffrey's tutorial on how to display threads and their replies, But then he displays the owner of the reply using {{ $reply->owner->name }} but when I do the same, Nothing shows on my page. It doesn't give me an error either. The same happens when I try to display the owner of the post, using {{ $post->owner->name }}

My Post model looks like this:


public function user() {
        return $this->belongsTo(User::class);
    }

    public function replies() {
        return $this->hasMany(Reply::class);
    }

    public function owner() {
        return $this->belongsTo(User::class, 'user_id');
    }

And my Reply model looks like this:

public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function post()
    {
        return $this->belongsTo(Post::class);
    }

    public function owner() {
        return $this->belongsTo(User::class, 'user_id');
    }

I don't think there is anything wrong with my relations

What is causing this problem? Thanks in advance!

Rainieren left a reply on Laravel - Get The Name Of A Channel Assigned To Post • 1 month ago

I have set my relations, In my post model I put

public function channel() {
        return $this->belongsTo('App/Channel');
    }

and in my channel model, I put

public function posts() {
        return $this->hasMany('App\Post');
    }

But this does not work. It gives me the error Call to undefined method Illuminate\Database\Query\Builder::all()

What can I do?

Rainieren started a new conversation Laravel - Get The Name Of A Channel Assigned To Post • 1 month ago

Hello, I'm starting a project, and now I need to display all my posts on the front page. I got that working and there is not a problem at that point. The problem is, each post is assigned to a channel, and each channel has a name. Currently, I can only fetch the channels id by doing this $post->channel_id but how can I fetch its name too? So I can do something like $post->channel->name and get the name of the channel where the post is in.

The controller I use looks like this:

public function index()
    {
        $posts = Post::all();
        return view('posts.questions')->with('posts', $posts);
    }

The model for channel is simply named Channel. How can i achieve this?

Thanks in advance!

Rainieren left a reply on Laravel - Integrity Contraint Violation: 1062 Duplicate Entry. • 1 month ago

I got it working! Thanks for the help!

9th November, 2017

Rainieren left a reply on Laravel - Integrity Contraint Violation: 1062 Duplicate Entry. • 1 month ago

I followed jeffrey_way's forum tutorial, He did it the exact same way, The problem is, The slug needs to be unique, But when 2 people have the same slug, He wrote some code to add an integer to it to make it unique, But I don't understand this error at all, In his tutorial it worked perfectly fine. @robrogers3 had the same issue and he fixed it, but his code does not work for me. Here is the link to the tutorial I followed: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/75

Rainieren left a reply on Laravel - Integrity Contraint Violation: 1062 Duplicate Entry. • 1 month ago

I added the top block of code to my Posts Model, and I edited my seed, But unfortunately, I still receive the same error. Also, The method you call called "update" does not exist in my case, I don't know if it exists but PHPStorm says it does not. Do you have any other solutions?

Since my thing is called "Post" I changed my code to this:

     protected $fillable = [
        'user_id', 'title', 'channel_id', 'text', 'slug'
    ];

    protected static function boot()
    {
        parent::boot();

        static::created(function ($post) {
            $post->update(['slug' => str_slug($post->title)]);
        });
    }

And I changed my seed to what you said, Do you maybe have any ideas what is causing this?

Rainieren left a reply on Laravel - Integrity Contraint Violation: 1062 Duplicate Entry. • 1 month ago

I think I see the problem, In my migration, I set the slug to be unique and In my seed, I assinged the title to be equal to the slug, And that cannot be done because slug is unique, But in Jeffrey's tutorial he has done the same, How can I solve this?

Rainieren started a new conversation Laravel - Integrity Contraint Violation: 1062 Duplicate Entry. • 1 month ago

Hello, I've been struggling with the problem for quite some time now and I'm getting a little bit desperate for a solution because I'm not that great at problem-solving. Anyway, I am trying to seed my database, And I followed a tutorial of Jeffrey in the series (forum) where he adds a slug to a thread. Well, I'm trying to do the same to my posts but when I seed my database I get the error stated in the title, What is causing this?

I got my migration here:

public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->Unsignedinteger('user_id');
            $table->Unsignedinteger('channel_id');
            $table->string('title');
            $table->longText('text');
            $table->string('slug')->unique();
            $table->timestamps();
        });
    }

And this is what I'm trying to do with my seeder:

public function run()
    {
        $faker = Faker\Factory::create();
        $title = $faker->sentence;

        foreach(range(1, 30) as $index) {
            DB::table('posts')->insert([
                'user_id' => rand(1, 50),
                'channel_id' => rand(1,14),
                'title' => $faker->sentence,
                'slug' => str_slug($title),
                'text' => $faker->paragraph,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);

        }
    }

And for the sake of keeping this question short, I'll show the full error code in a picture which is: https://imgur.com/a/ntQMX

Thanks for looking into my problem!

6th November, 2017

Rainieren left a reply on Laravel - Like \ Dislike System • 1 month ago

Okay, I understand the concept of Polymorphic relations, Likeable_ID can be either Post_id or Reply_id. But how can I make it work in my project? Say for instance a put this in my project, How can I make the user click on the like or dislike button and then the number besides the button goes +1? @PaulDiamant In your migration you put like_type, 0 Is dislike, and 1 is like. But can I achieve the above with that?

Edit Your Profile
Update

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