Rainieren

Rainieren

Groningen

Member Since 1 Year Ago

Experience Points 6,750
Experience
Level
Lessons Completed 23
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

23 Apr
6 months ago

Rainieren started a new conversation SSH Into Server Using Server-IP And Run Commands

Hello, I've been trying to get something done for a long while now with no success, I'm trying to SSH into a server using an IP of a server that was created and run commands on that specific server.

I have a system where droplets(servers) get created. After a while, I receive the IP of this server and I somehow need to manage to connect to these servers and run commands. My try was to do something like this

$droplet = Droplet::where("webshop_id", "=", $id)->get();

        \SSH::into($droplet->ip)->run([
           'cd var/home',
        ]);

But that doesn't work. How can I make this work? I've looked on https://laravelcollective.com/docs/5.4/ssh but I can't find my solution there.

The IP varies per created server so using remote.php is not an option except if it can be changed dynamically

19 Apr
7 months ago

Rainieren started a new conversation Laravel - Make SSH Connection To Server

I've been struggling with this problem for a while now and I'm running out of ideas to try. I have a system where a user can follow some basic steps, After he/she finishes these steps, A remote server (Droplet) will be created by using the DigitalOcean API. Via a script, I receive the data of the newly created server in my database. Data such as IP, Droplet ID etc, which I can use in the future.

I'm able to access the newly created server by doing, for instance, [email protected] in a console (Opening the CMD and typing that command) without the need of a password or username, So there's that. Now I need to be able to connect to this newly created server using my code and be able to perform commands on it once I've connected to it. How can I accomplish this?

Code: OrderController (This creates the server of which I receive the IP from, about 1 minute after it's creation.)

$droplet = DigitalOcean::droplet()->create($storeName, 'ams3', 's-1vcpu-1gb', $images[0]->id, false, false, false, $keyArray, strval($webshop->id), true, [], [strval($webshop->id)]);

12 Apr
7 months ago

Rainieren started a new conversation Laravel JQuery - Check If Record Exists In Database

In my application, I build a page where the user sees a progress bar which displays the progress of an action that is happening in the background. One part of this progress bar is the following: I have to check in jQuery if a certain row with a certain id exists in the database. If it does exist, The progress bar has to skip to 30%. If it does not exists then It has to do nothing.

I have a database table called Droplets, In there-there is a field called Webshop_id. If a Droplet exists in this table which has the webshop_id of the one that the user just created, The progress bar goes to 30%.

A small summary to clarify

  • Check if a droplet with the webshop_id exists in the database using jQuery
  • If it does exist, Make the progress bar a width of 30%;
  • If it does NOT exists. Do nothing.

A simple if-statement in PHP of this issue would look something like this

if( Droplet::where("webshop_id", "=", $webshop->id)->exists())

    Make the progress bar 30% in width

else {

    Just do nothing

}

But this needs to be done in jQuery in order to make the progress bar a width of 30%. What is the best way to handle this issue?

The page where this needs to happen looks like this.

@extends('layouts.home') @section('content')

      <div class="row">
        <div class="col-md-12 text-right">
          <h3>37%</h3>
        </div>
        <div class="col-md-12 mb-3">
          <div class="progress mb-3">
            <div id="progress-install" class="progress-bar andcode-progress progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width: 10%"></div>
          </div>
        </div>
        <div class="col-md-12 text-right">
          <a href="" class="btn btn-orange disabled">See the result</a>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
</div>

{{ $webshop->id }}

<script>
  $(document).ready(function() {
      var checkdb = function() {
   
      var ele = document.getElementById('progress-install');
      ele.style.width = 30 + '%';
   };
   setInterval(checkdb(), 1000 * 60);
 })
 </script>
 @endsection

I can call {{ $webshop->id }} anytime in this blade file. This ID has to match to the "Webshop_ID" in the droplets table, If there is a record in the db where the webshop_id matches the webshop_id in the droplets table. The progress bar has to skip to 30%. How can I achieve this?

23 Mar
7 months ago

Rainieren started a new conversation Laravel - Generate Unique Order Number

Hello, I'm currently trying to generate a unique order number when the user reaches the create method. The order numbers are generated like this in the seed and need to look like this as well

Seed

foreach(range(1,25) as $index)
        {
            DB::table('orders')->insert([

                'user_id' => rand(1,25),
                'order_nr' => '#' . sprintf("%08d", $index),
                'price_sum' => $faker->randomNumber($nbDigits = 4, $strict = false) . '.' . $faker->randomNumber($nbDigits = 2, $strict = false),
                'status' => $faker->randomElement(['paid', 'pending', 'failed']),
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),

            ]);
        }

The order numbers look like this #00000001 or #00000002. Now when the user reaches the create method in my controller a new unique order number in this sequence needs to be created. How can I achieve that? The controller currently looks like this:

 public function create()
    {
        $order = new Order;

        $order->user_id = Auth()->id();
        $order->order_nr = 


        dd($order);


        return view('steps.order');
    }

It needs to check the latest order number and create one with +1 on that order number. Say for instance there are 25 orders and the last one is #00000025 the one that needs to be created next needs to be #00000026. How can I achieve that?

21 Mar
7 months ago

Rainieren started a new conversation Laravel - Create Order_nr Sequence

Hello, I'm trying to create an order_nr sequence, for instance, ORD000001, ORD000002. I'm trying to do this in my seeder. In my OrderSeederTable, I have a foreach loop which does the following:

foreach(range(1,25) as $index)
        {
            DB::table('orders')->insert([

                'user_id' => rand(1,25),
                'webshop_id' => rand(1, 20), 
                'order_nr' => $faker->unique()->randomNumber($nbDigits = NULL, $strict = false),
                'price_sum' => 1234.56,
                'status' => $faker->randomElement(['paid', 'pending', 'failed']),
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),

            ]);
        }

How can I make the order_nr in that sequence? That every order_nr goes +1. with ORD in front of it? Currently i'm just renerating random numbers. Thanks in advance!

19 Mar
8 months ago

Rainieren started a new conversation Laravel - Select Item Get Attributes And Submit Form

I'm working on a project which requires a function where the user can select an item and click on the "Next" button to submit the form. The problem is, I don't know how to make this work. I have blade template which has an a form. Within that form, I display all the products using a foreach loop. The user needs to be able to select ONE product from this list and click on next to confirm his choice.

This is the blade template

@extends('layouts.home') @section('content')
<div class="container" id="showEffect">
<div class="row">
<div class="col-md-12">
  <form method="POST" action="{{ route('saveTheme') }}">
    {{ csrf_field() }}
    <input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
    <div class="card depth-1">
      <div class="card-body">
        <div class="row">
          <div class="col-md-3 items-center-left">
            <a href="{{ route('mainsettings') }}" class="back-link">
              <p class="m-0"><i class="fal fa-chevron-left fa-lg mr-2"></i> <span style="font-size: 24px;">Go back</span></p>
            </a>

          </div>
          <div class="col-md-3 text-right items-center-right">
            <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Next</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
          </div>
        </div>
      </div>
    </div>

    <div class="row mt-4">
      @foreach($themes as $theme)
      <div class="col-md-4 mb-4">
        <div class="card theme-card card-hover depth-2 border-0" id="theme-id-{{$theme->id}}">
          <a href="" class="theme-link" data-toggle="modal" data-target="#theme{{ $theme->id }}">

            <div class="card-header p-0">
              @if($theme->thumbnail != 0)
              <img src="https://s.tmimgcdn.com/scr/67400/magento-thema-over-boxen_67400-original.jpg?width=502&height=502" width="502" height="350" class="theme-card-img" alt=""> @else
              <img src="http://jis.gov.jm/media/blank.png" class="theme-card-img" alt=""> @endif
            </div>
            <div class="card-body">
              <div class="row">
                <div class="col-md-2 vertical-center">
                  <i class="fab fa-magento fa-lg"></i>
                </div>
                <div class="col-md-10">
                  <p class="m-0">{!! str_limit($theme->name, $limit = 32, $end = '...') !!}</p>
                  <small>Magento template</small> {{--{{ $themes->composer_package }}--}}
                </div>

              </div>
            </div>
          </a>

          <div class="card-footer bg-white border-0 text-right pt-0">
            <div class="row">

              <div class="col-md-6 text-left">
                <button data-card-id="{{$theme->id}}" class="btn btn-orange btn-sm btn-theme-choice">Kiezen</button>
              </div>
              <div class="col-md-6 text-right">
                <small class="text-muted" style="text-decoration: line-through">145 €</small><span style="font-size: 20px;"> {{ $theme->price }} €</span>
              </div>
            </div>

          </div>
        </div>
      </div>

      @endforeach
    </div>

    <div class="row mt-4 mb-5">
      <div class="col-md-6 items-center-left">
        <a href="{{ route('mainsettings') }}" class="back-link">
          <p class="m-0"><i class="fal fa-chevron-left fa-lg mr-2"></i> <span style="font-size: 24px;">Terug</span></p>
        </a>

      </div>
      <div class="col-md-6 text-right">
        <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Volgende stap</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
      </div>
    </div>
  </form>
</div>
</div>
</div>

<div class="andcode-clouds">

</div>

@endsection

The chosen theme needs to be saved in a session array like this:

foreach($this->predefinedArray as $value) {
        $request->session()->put('chosen_theme.' . $value, $request->input($value));
    }

PredefinedArray consists of all the fillable fields of the class product Then I get an array with the attributes of the chosen product and I can retrieve the information of that product, Like the name and description like this. session('chosen_theme.name).

How can I make the products selectable and retrieve their info and then submit the main form? Thanks in advance.

Also, Here is a small demonstration of what I want to achieve so you get a visual idea: https://imgur.com/a/tX7Ue

15 Mar
8 months ago

Rainieren started a new conversation Laravel - Select A Card And Go To Next Step

Hello, I'm making a project which needs to give the user the option to select a specific card by clicking on a button within that card. When the user made the right choice they'll press the "next" button in the top right corner and their choice gets submitted. How can I accomplish this?

The layout of the form looks like this:


<form method="POST" action="{{ route('saveTheme') }}" >
                    {{ csrf_field() }}
                    <input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
                    <div class="card depth-1">
                        <div class="card-body">
                            <div class="row">                              
                                <div class="col-md-12 text-right items-center-right">
                                    <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Next Step</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row mt-4">
                        @foreach($themes->products as $theme)
                        <div class="col-md-4 mb-4">
                            <a href="" class="theme-link" data-toggle="modal" data-target="#theme{{ $theme->id }}">
                                <div class="card theme-card card-hover depth-1 border-0">
                                    <div class="card-header p-0">
                                        @if($theme->thumbnail != 0)
                                        <img src="https://s.tmimgcdn.com/scr/67400/magento-thema-over-boxen_67400-original.jpg?width=502&height=502" width="502" height="350" class="theme-card-img" alt="">
                                        @else
                                            <img src="http://jis.gov.jm/media/blank.png" class="theme-card-img" alt="">
                                        @endif
                                    </div>
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-md-2 vertical-center">
                                                <i class="fab fa-magento fa-lg"></i>
                                            </div>
                                            <div class="col-md-7">
                                                <p class="m-0">{!! str_limit($theme->name, $limit =  21, $end = '...') !!}</p>
                                                <small>Magento template</small>
                                            </div>
                                            <div class="col-md-3 vertical-center">
                                                <button class="btn btn-success btn-sm btn-theme-choice">Kiezen</button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="card-footer bg-white border-0 text-right pt-0">
                                        <small class="text-muted" style="text-decoration: line-through">145 €</small><span style="font-size: 20px;" > {{ $theme->price }} €</span>
                                    </div>
                                </div>
                            </a>
                        </div>
                       
                    <div class="row mt-4 mb-5">
                       
                        <div class="col-md-12 text-right">
                            <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Volgende stap</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
                        </div>
                    </div>
                </form>

Each card is in an anchor tag. So each card is selectable. (They can only choose ONE card)

When the user made their choice (By clicking on a card) and they click on the "Next" button to go to the next page. The theme's choice needs to be saved in a session like this: $request->session()->put('theme_choice', $request->all()); And with the request comes all the data of the selected card.

I honestly have no clue how to make this work. Also, the user needs some kind of feedback. That, if the user chose the product, The card gets a green border for example. But this can easily be done with jQuery I assume.

How can I accomplish this? Thanks in advance!

14 Mar
8 months ago

Rainieren started a new conversation Laravel - Follow A Collection Of Routes In Order

I have a project which requires a step-program. Which means that a user needs to follow a collection of routes in order. Say, for instance, there are 5 steps. the routes for those steps are www.example.com/step1, www.example.com/step2 etc. The user must fill in the form on www.exmaple.com/step1 before being able to access www.example.com/step2. If the user did not fill in the form on step1. he/she can't access step 2, 3, 4 or 5 either. They must follow the routes in order of 1, 2, 3, 4, 5. How can I make this work? I figured I had to use something like middleware? I honestly have no clue where to look. Tips are appreciated

Thanks in advance!

06 Mar
8 months ago

Rainieren started a new conversation Laravel - Get Last Session Array

Hello, I'm making a step program and therefore I want to use session. I found a way to push all the input values in an array called "basic_settings" like this $request->session()->push('basic_settings', $request->input()); And I found a way to display the first session's specific items in the view like this {{ Session::get('basic_settings')[0]['store_name'] }} But if the user starts again, a new session array will be made called "basic_settings" with the new values, So the other one becomes outdated. How can I display the most recent items from the session in my view? Thanks in advance!

02 Mar
8 months ago

Rainieren started a new conversation Laravel - Save Input Values For Later

Hello, I'm planning to make a step-by-step plan in Laravel where the user can put in some information and move on to the next step. But for each step, I want to prevent it from injecting the data into the database but instead, save them somewhere to inject them later when a certain phase of the step-program has finished. I want to do this to prevent junk in the database if the user decided to bail at a random step. Where do I need to look to make this work? I'm not that good of a programmer, Do have in mind.

Thanks in advance!

26 Jan
9 months ago

Rainieren left a reply on JQuery Save ToggleClass In LocalStorage

Nevermind. Solved it already. Jeffrey needs to add the feature to remove posts ;-)

Rainieren started a new conversation JQuery Save ToggleClass In LocalStorage

Hello, I made a sidebar and I want to save the status of the sidebar for users. If they choose to pick the "Collapsed" version of the sidebar, If they refresh the page the sidebar still stays that way. I know I can use localStorage with this but I don't know how.

Code

$(document).ready(function() {

    $('#sidebar-toggler').on('click', function() {
        $('#sidebar').toggleClass('active');
        $('#navbar-brand').toggleClass('active');
        $('#content').toggleClass('active');
    });

});

How can I achieve the above? Thanks in advance

18 Jan
10 months ago

Rainieren started a new conversation Bootstrap 4 - Fixed Navbar Full Width Collumn

Hello, I'm making a dashboard and I want to have a fixed navbar in bootstrap that is the full width of my column which is col-md-10 But when I add position: fixed; to the navbar the navbar stretches 100% across the whole page instead of staying in the column. How can I solve this? Here is an image of what I am trying to achieve: https://imgur.com/a/xp4mC The navbar needs to be the full width of the blue column. In the picture it is but it does not have position: fixed;, If I add that, however. It will look like this.: https://imgur.com/a/GYdYQ

Here is the code:

<div class="container" style="max-width: 100%; margin: 0;">
    <div class="row">
        <div class="col-md-2" style="background-color: red; height: 100px;">



        </div>
        <div class="col-md-10" style="background-color: blue; height: 100px; padding: 0;">

            <nav class="navbar navbar-expand-lg navbar-light z-depth-3 border-none" style="background-color: #ffffff; padding-top: 12px; padding-bottom: 12px;">
                <div class="container-fluid" style="padding-left: 0;">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <a class="navbar-brand" href="#">Navbar</a>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav mr-auto">
                            <li class="nav-item">
                            </li>
                        </ul>

                        <ul class="navbar-nav">
                            <li class="nav-item">
                                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <span class="hidden-xs-only">John Doe</span>
                                </a>
                                <div class="dropdown-menu pull-right" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="#">Action</a>
                                    <a class="dropdown-item" href="#">Another action</a>
                                    <a class="dropdown-item" href="#">Something else here</a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>

        </div>
    </div>
</div>

How can I solve this?

Thanks in advance

26 Nov
11 months ago

Rainieren started a new conversation Laravel - Delete User With Anchor Tag

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!

25 Nov
11 months ago

Rainieren started a new conversation Laravel - Search Through Table By Name & Pagination

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!

23 Nov
11 months ago

Rainieren started a new conversation Laravel - Active Status When On Current Page

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

Nevermind ignore this

Rainieren started a new conversation Laravel - Show Latest 5 Registered Users

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.

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

21 Nov
11 months ago

Rainieren started a new conversation Laravel 5.5 - Create Seperate Admin Panel Login Page

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.

16 Nov
1 year ago

Rainieren left a reply on Laravel - POST 422 (Unprocessable Entity)

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)

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)

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)

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)

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

15 Nov
1 year ago

Rainieren left a reply on Laravel - Connection Could Not Be Established With Host

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

@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

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!

13 Nov
1 year ago

Rainieren left a reply on Laravel - Unexpected Token }

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 }

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'

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'

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'

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'

@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'

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

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

@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

@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,

12 Nov
1 year ago

Rainieren started a new conversation Laravel - VueJS Replies Not Displaying

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.

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

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

@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

@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

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

11 Nov
1 year ago

Rainieren started a new conversation Laravel - VueJS Adding Transitions To Flash Message

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

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

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

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

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!