Rainieren

Rainieren

Member Since 3 Years Ago

Groningen

Experience Points
8,010
Total
Experience

1,990 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
24
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 2
8,010 XP
May
11
3 weeks ago
Activity icon

Started a new Conversation Binary Tree From 1 To 10 In All Traversals The Same Result

Hello, I have a question for an assignment which I don't really get. There is a question that states: Create a binary tree that stores digits from 1 to 10 where the result for an in-order, pre-order and post-order traversal is the same. Applying the rules I found on various websites, this can't be done right? Because when you create a binary tree with a node of let's say 6 and the most left leaf is 1. The result of a in-order traversal would be

8... ... ... ... ...

and the order of a pre-order would be

1... ... ... .. ...

Am I doing something wrong?

Mar
25
2 months ago
Activity icon

Started a new Conversation Laravel - Column Not Found Orders.user_id

I am designing a system where the user can subscribe to a plan and can also make single item payments. For the subscription part I am using Laravel Mollie Cashier and for the single item payment part I figured I could use the same tables that Cashier generates, which are orders, order_items and subscriptions.

I made a couple of models to tie all the tables together. So in the user model I've put the hasMany relation

public function orders() {
        return $this->hasMany(Order::class);
    }

And I made a Orders model where i've put the belongsTo model

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

The error I get is actually really obvious because the generated table orders does not have a user_id but instead is called owner_id (See below)

Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('owner_type');
            $table->unsignedBigInteger('owner_id');
            $table->string('number');
            $table->string('currency', 3)->nullable();
            $table->integer('subtotal');
            $table->integer('tax');
            $table->integer('total');
            $table->integer('balance_before')->default(0);
            $table->integer('credit_used')->default(0);
            $table->integer('total_due');
            $table->string('mollie_payment_id')->nullable();
            $table->string('mollie_payment_status', 16)->nullable();
            $table->datetime('processed_at')->nullable();
            $table->timestamps();
        });

I though I could fix this by adding the following line to the schema

$table->foreign('owner_id')->references('id')->on('users');

But this results in the same error. I tried adding ->nullable() or ->unsigned() to the owner_id field but that also gave the same result.

I also tried adding the following:

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

But that also does not solve the problem. How can I fix this issue so I can do a simple foreach loop like this?

@foreach($user->orders as $order):

@endforeach

NOTE: I can't simply change the owner_id to be called user_id because that will break Cashier-mollie. When a new subscription is created it inserts the Auth's ID into the owner_id field.

Mar
19
2 months ago
Activity icon

Started a new Conversation Laravel CSRF - 419 Page Expired With Post Request To Other Website

Currently I am working on 2 websites. One website(Website A) is a simple CMS and the other website(Website B) is a regular website for the user where they can manage their profiles etc. The user can browse packages in the CMS. These packages are received using an AJAX request from the other site (Website B). these packages can also be bought. When the user buys a package(Website A), a post request is being send to the other website(Website B).

So to clarify, Say, for instance we have websites A and B. When the user on website A buys a package, a post request is being send to "B.com/package/purchase". There is only one problem with this design. In Laravel a csrf token has to be send with every form. Because I do a POST request to another website, I cannot generate a CSRF token from website A, because then the request will always be expired. So I have to use the CSRF token from website B. I have tried that but the request still returns a 419 Page Expired error. How can I solve this?

The form on Website A: (This form is inside an javascript append, thus the quotes.

'<form method="POST" action="https://rainierlaansite.test/package/' + el.token +'/purchase" id="purchase-form">' +
    '<input type="hidden" value="'+ el.token +'" name="package_token">' +
    '<input name="_token" type="hidden" id="csrf-token" value=' + data[1] + '>' +
      '<h4>' +
        '<a href="#" id="download_package" class="badge badge-pill '+ (el.price == 0 ? 'badge-primary': 'badge-light') +'" onclick="document.getElementById(\'purchase-form\').submit();">' +
            (el.price == 0 ? 'Download': '$ ' + el.price) +
        '</a>' +
      '</h4>' +
'<form>' +

The AJAX request on website A:

<script>
        $.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'X-Requested-With': 'XMLHttpRequest'},
            url: 'https://www.rainierlaansite.test/api/packages/get',
            type: 'GET',
            data: {},
            success: function(data) {
                $('#package-loading').fadeOut();
                let wrapper = $("#packages-wrapper");
                let popup_list = $('.popup-list');
                let popup = 'popup-id';

                if(data == null) {
                    console.log('lol')
                }
                $.each(data[0], function(index, value) {
                    let el = data[0][index];
                    wrapper.append(
                        '<div class="row my-4" data-id='+ el.id +'>' +
                            '<div class="col-2 d-flex justify-content-center"><i class="fad fa-archive fa-2x"></i></div>' +
                            '<div class="col-6">' +
                                '<a href="#" class="popup" data-popup-id="'+ el.id +'"><h6 class="m-0">'+ el.name +'</h6></a>' +
                                '<p class="m-0 sub-text">'+ el.description +'</p>' +
                            '</div>' +
                            '<div class="col-4 d-flex justify-content-end align-items-center">' +
                                '<a href="#" id="download_package" class="badge badge-pill badge-light popup '+ (el.price == 0 ? 'badge-primary': 'badge-light') +'" style="font-size: 14px;" data-popup-id="'+ el.id +'">' + (el.price == 0 ? 'Download': '$ ' + el.price) +'</a>' +
                            '</div>' +
                        '</div>' + '<hr>'
                    );
                    popup_list.append(
                        '<div class="package-popup shadow popup-'+ el.id +'">' +
                            '<div class="package-popup-dialog animated zoomIn show faster">' +
                                '<div class="package-popup-content">' +
                                    '<div class="row">' +
                                        '<div class="col-2">' +
                                            '<div class="row">' +
                                                '<div class="col-12 d-flex justify-content-center">' +
                                                    '<i class="fad fa-archive fa-3x"></i>' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                        '<div class="col-7">' +
                                            '<div class="row">' +
                                                '<div class="col-12">' +
                                                    '<h4 class="m-0">' + el.name + '</h4>' +
                                                    '<p class="sub-text">' + el.creator + '</p>' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                        '<div class="col-3 text-center">' +
                                            '<form method="POST" action="https://rainierlaansite.test/package/' + el.token +'/purchase" id="purchase-form">' +
                                                '<input type="hidden" value="'+ el.token +'" name="package_token">' +
                                                '<input name="_token" type="hidden" id="csrf-token" value=' + data[1] + '>' +
                                                '<h4>' +
                                                    '<a href="#" id="download_package" class="badge badge-pill '+ (el.price == 0 ? 'badge-primary': 'badge-light') +'" onclick="document.getElementById(\'purchase-form\').submit();">' +
                                                    (el.price == 0 ? 'Download': '$ ' + el.price) +
                                                    '</a>' +
                                                '</h4>' +
                                            '<form>' +
                                        '</div>' +
                                        '<div class="offset-2 col-7">' +
                                            '<div class="rating">' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star grey"></i></span>' +
                                                '<small><a href="">· Uit 300 beoordelingen</a></small>' +
                                            '</div>' +
                                            '<small>Nog geen beoordelingen</small>' +
                                        '</div>' +
                                        '<div class="col-3 text-center">'+
                                            '<i class="far fa-download"></i> ' + el.downloads +
                                        '</div>' +
                                    '</div>' +
                                    '<div class="row my-5">' +
                                        '<div class="col-12">' +
                                            '<nav>' +
                                                '<div class="nav nav-tabs" id="nav-tab" role="tablist">' +
                                                    '<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Details</a>' +
                                                    '<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Reviews</a>' +
                                                    '<a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">Version history</a>' +
                                                '</div>' +
                                            '</nav>' +
                                            '<div class="tab-content" id="nav-tabContent">' +
                                                '<div class="tab-pane fade show active py-4" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">' +
                                                    '<p>' + el.description + '</p>' +
                                                '</div>' +
                                                '<div class="tab-pane fade py-4" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">' +
                                                    'Dit is twee tekst' +
                                                '</div>' +
                                                '<div class="tab-pane fade py-4" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">' +
                                                    'Dit is tekst 3' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                    '</div>' +
                                '</div>' +
                            '</div>' +
                        '</div>'
                    );
                });

                $('.popup').on('click', function () {
                    if($(this).data(popup)) {
                        let item = $('.popup-' + $(this).data(popup));
                        item.addClass('show');
                        $(item).on('click', function(event) {
                            if (event.target.classList.contains("shadow")) {
                                item.removeClass('show');
                            }
                        })
                    }
                });
            },
            error: function(e) {
                $('#package-error').fadeIn().text("Unfortunately there was an error retrieving the packages");
            }
        });
    </script>

What the AJAX request receives

 public function get()
    {
        $csrf = json_encode(csrf_token());
        return response()
            ->json([Package::all(),  $csrf]);
    }
Mar
16
2 months ago
Activity icon

Replied to CSS & JS - Remove Modal When Clicked On Background

How can I best implement this with my current code? I don't know how handlers work?

Activity icon

Started a new Conversation CSS & JS - Remove Modal When Clicked On Background

Currently I am making my own modal for my system. When you click on the name of a package the modal popups up and displays. I added some JQuery that is supposed to remove the modal when clicked on the background. It does that but also when I click on the modal itself it hides.

I tried adding z-index 3 to the parent and z-index 4 to the modal but that does not work. How can I make it so that if clicked on the background, the modal disappears but when clicked on the modal itself it does nothing and people can just interact normally with the modal?

I have a small illustration

https://i.stack.imgur.com/mFEn1.gif

The popups are appended to a parent using Ajax (See below)

<div class="container-fluid pt-5 ">
        <div class="row">
            <div class="col-md-6">
                <h3>{{ __('Packages') }}</h3>
            </div>
        </div>
        <div class="row my-5">
            <div class="col-md-4">
                <div id="package-loading" class="text-center">
                    <i class="fas fa-spinner fa-pulse fa-2x color-primary"></i>
                </div>
                <p id="package-error" class="text-danger" style="display: none"></p>
                <div id="packages-wrapper"></div>
            </div>
        </div>
    </div>
    <div class="popup-list">

    </div>

    <script>
        $.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'X-Requested-With': 'XMLHttpRequest'},
            url: 'https://www.rainierlaansite.test/api/packages/get',
            type: 'GET',
            data: {},
            success: function(data) {
                $('#package-loading').fadeOut();
                let wrapper = $("#packages-wrapper");
                let popup_list = $('.popup-list');
                let popup = 'popup-id';

                if(data == null) {
                    console.log('lol')
                }
                $.each(data, function(index, value) {
                    let el = data[index];
                    wrapper.append(
                        '<div class="row my-4" data-id='+ el.id +'>' +
                            '<div class="col-2 d-flex justify-content-center"><i class="far fa-archive fa-2x"></i></div>' +
                            '<div class="col-6">' +
                                '<a href="#" class="popup" data-popup-id="'+ el.id +'"><h6 class="m-0">'+ el.name +'</h6></a>' +
                                '<p class="m-0 sub-text">'+ el.description +'</p>' +
                            '</div>' +
                            '<div class="col-4 d-flex justify-content-end align-items-center">' +
                                '<a href="#" id="download_package" class="badge badge-pill badge-light popup '+ (el.price == 0 ? 'badge-primary': 'badge-light') +'" style="font-size: 14px;" data-popup-id="'+ el.id +'">' + (el.price == 0 ? 'Download': '$ ' + el.price) +'</a>' +
                            '</div>' +
                        '</div>' + '<hr>'
                    );
                    popup_list.append(
                        '<div class="package-popup shadow popup-'+ el.id +'">' +
                            '<div class="package-popup-dialog">' +
                                '<div class="package-popup-content">' +
                                    '<div class="row">' +
                                        '<div class="col-2">' +
                                            '<div class="row">' +
                                                '<div class="col-12 d-flex justify-content-center">' +
                                                    '<i class="far fa-archive fa-3x"></i>' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                        '<div class="col-7">' +
                                            '<div class="row">' +
                                                '<div class="col-12">' +
                                                    '<h4 class="m-0">' + el.name + '</h4>' +
                                                    '<p class="sub-text">' + el.creator + '</p>' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                        '<div class="col-3 text-center">' +
                                            '<h4><a href="#" id="download_package" class="badge badge-pill '+ (el.price == 0 ? 'badge-primary': 'badge-light') +'">' +
                                                (el.price == 0 ? 'Download': '$ ' + el.price) +
                                            '</a></h4>' +
                                        '</div>' +
                                        '<div class="offset-2 col-7">\n' +
                                            '<div class="rating">\n' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star yellow"></i></span>' +
                                                '<span><i class="fas fa-star grey"></i></span>' +
                                                '<small><a href="">· Uit 300 beoordelingen</a></small>' +
                                            '</div>' +
                                            '<small>Nog geen beoordelingen</small>' +
                                        '</div>' +
                                        '<div class="col-3 text-center">'+
                                            '<i class="far fa-download"></i> ' + el.downloads +
                                        '</div>' +
                                    '</div>' +
                                    '<div class="row my-5">' +
                                        '<div class="col-12">' +
                                            '<nav>' +
                                                '<div class="nav nav-tabs" id="nav-tab" role="tablist">' +
                                                    '<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Details</a>' +
                                                    '<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Reviews</a>' +
                                                    '<a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">Version history</a>' +
                                                '</div>' +
                                            '</nav>' +
                                            '<div class="tab-content" id="nav-tabContent">' +
                                                '<div class="tab-pane fade show active py-4" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">' +
                                                    '<p>' + el.description + '</p>' +
                                                '</div>' +
                                                '<div class="tab-pane fade py-4" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">' +
                                                    'Dit is twee tekst' +
                                                '</div>' +
                                                '<div class="tab-pane fade py-4" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">' +
                                                    'Dit is tekst 3' +
                                                '</div>' +
                                            '</div>' +
                                        '</div>' +
                                    '</div>' +
                                '</div>' +
                            '</div>' +
                        '</div>'
                    );
                });

                $('.popup').on('click', function () {
                    if($(this).data(popup)) {
                        let item = $('.popup-' + $(this).data(popup));
                        item.addClass('show');
                        $(item).on('click', function() {
                            item.removeClass('show');
                            console.log('ik klik op de achtergrond');
                        })
                    }
                });
            },
            error: function(e) {
                $('#package-error').fadeIn().text("Unfortunately there was an error retrieving the packages");
            }
        });
    </script>

HTML

SASS

.package-popup
    position: fixed
    top: 0
    left: 0
    height: 100%
    width: 100%
    display: none
    overflow: hidden
    background-color: $primary_background_transparent
    z-index: 3
    .package-popup-dialog
        max-width: 960px
        position: relative
        margin: auto
        top: 100px
        background-color: $color-white
        border-radius: 16px
        padding: 3rem
        z-index: 4
        pointer-events: none
        .package-popup-content
            position: relative
            pointer-events: auto
            display: flex
            flex-direction: column
Activity icon

Started a new Conversation Laravel 6 - Import FontAwesome SASS Not Displaying

I downloaded the pro zip of FontAwesome 5 and put in inside my resources/sass folder. Next I imported it in my app.scss file like this:

// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');

// Variables
@import 'variables';

// Bootstrap
@import '~bootstrap/scss/bootstrap';

// FontAwesome
@import "fontawesome/scss/fontawesome";

@import "theme";

But my icons are not showing and my console doesn't show a single error. What is causing this and why isn't it working? The path is correct.

Jan
30
4 months ago
Activity icon

Started a new Conversation JQuery - Foreach Html With Data

I made an Ajax API call that returns an object with data. I have a HTML structure that I wish to repeat for every object that the API call returns and with the relevant data. How can I accomplish that?

Ajax call

 $.ajax({
    headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'X-Requested-With': 'XMLHttpRequest'},
    url: 'https://www.rainierlaansite.test/api/packages/get',
    type: 'GET',
    data: {},
    success: function(data) {
         $('#package-loading').fadeOut();
         $.each(data, function(index, value) {
             console.log(index);
             console.log(value)
          });
     },
    error: function(e) {
        $('#package-error').fadeIn().text("Unfortunately there was an error retrieving the packages");
    }
 });

The api call returns the following object

id: 1
name: "rainieren/visitors"
description: "The Laravel Framework."
subscription_id: 1
price: 0.99
composer_package: "rainieren/visitors"
downloaded: 8
created_at: "2020-01-28 21:48:39"
updated_at: "2020-01-28 21:48:39"

HTML Structure that needs to be repeated for every object.

<div class="row">
   <div class="col-2">
       foto
   </div>
   <div class="col-6">
        <a href=""><h6 class="m-0">Name</h6></a>
         <p class="m-0 sub-text">Description</p>
    </div>
     <div class="col-4 d-flex justify-content-end align-items-center">
          <a href="" class="badge badge-pill badge-light" style="font-size: 14px;">price</a>
      </div>
    </div>
    <hr>
Jan
28
4 months ago
Activity icon

Started a new Conversation Laravel - XMLHttpRequest While Trying To Retrieve Data From Api Call Ajax

I have 2 applications on my system. In one application I store packages and with the other I want to retrieve these package using an ajax api call. In my main project I have this ajax request which is supposed to retrieve data

setInterval(function(){
            $.ajax({
                headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'X-Requested-With': 'XMLHttpRequest'},
                url: 'https://www.rainierlaansite.test/api/packages/get',
                type: 'GET',
                data: {},
                success: function(data) {

                }
            });
        }, 10000);

Do have in mind that I am using valet. The url is local and secured using valet secure.

In my other project I have a route api/packages/get

Route::get('api/packages/get', '[email protected]')->name('get_packages');

Which returns all packages

public function get()
    {
        return Package::all();
    }

But for some reason I get this error:

Access to XMLHttpRequest at 'https://www.rainierlaansite.test/api/packages/get' from origin 'https://rainierlaan.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I came across this Stackoverflow post

https://stackoverflow.com/questions/43565877/no-access-control-allow-origin-header-laravel-5-4

which recommended to install barryvdh/laravel-cors. I followed the steps but without any luck. What can this be?

Jan
27
4 months ago
Activity icon

Replied to Laravel - Required Own Package, Can't Find Route

@bobbybouwmann Thank for your reply! If I run php artisan route:list the route /visitors does not show up. I added the \ and updated the package but unfortunately it does not make a difference. What can it be?

I have a warning in my terminal which likely has something to do with it https://imgur.com/i33SWpx

Activity icon

Started a new Conversation Laravel - Required Own Package, Can't Find Route

Hey everyone! I am completely new to developing packages and I had this great idea with my project. I made a simple package which consists of a single controller, a route and a view to see if the package actually works. The package itself works fine and I uploaded it to packagist. Everything went fine with no issues whatsoever.

When my package was uploaded I did composer require rainieren/visitors in my main project and it successfully required the package and it is inside my vendor folder.

The package I developed had a route which was /visitors and it returned a single string.

Route

Route::get('visitors', 'Rainieren\Visitors\Http\Controllers\[email protected]');

Controller

 public function index()
    {
        return view('visitors::home');
    }

View

<h1>Visitors page</h1>

After I required my own package using composer require rainieren/visitors I navigated to the /visitors url in my main project where I required the package. But my main project can't seem to find the route. I have a feeling i'm doing something wrong here. What can this possibly be?

Jan
06
4 months ago
Activity icon

Replied to Laravel - Store Blade In DB And Render?

@Sinnbeck I know that I have tried using that but it does not work

Activity icon

Replied to Laravel - Store Blade In DB And Render?

Yes I have tried that but it still does not render the blade portion correctly

Activity icon

Started a new Conversation Laravel - Store Blade In DB And Render?

I want to store a blade template in the database and render it as blade on my screen. In my system I have pages and a page has blocks, each block has a field called content Currently, I have a form in a block in my database, saved as longText like so:

<form action="{{ route('create_message') }}" method="POST">
                    @csrf
                    <div class="form-grouo row">
                        <div class="form-group col-6">
                            <label for="firstname">{{ __('Firstname') }}</label>
                            <input type="text" name="firstname" class="form-control" id="firstname">
                        </div>
                        <div class="form-group col-6">
                            <label for="lastname">{{ __('Lastname') }}</label>
                            <input type="text" name="lastname" class="form-control" id="lastname">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="email">{{ __('Email') }}</label>
                        <input type="email" name="email" class="form-control" id="email">
                    </div>
                    <div class="form-group">
                        <label for="title">{{ __('Title') }}</label>
                        <input type="text" name="title" class="form-control" id="title">
                    </div>
                    <div class="form-group">
                        <label for="message">{{ __('Message') }}</label>
                        <textarea name="message" id="message" class="form-control" cols="30" rows="10"></textarea>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">{{ __('Send form') }}</button>
                    </div>
                </form>

But the blade syntax such as @csrf or {{ route('send_message') }} or {{ __('Firstname') }} do not work when I render it like the following {!! $page->content !!}.

@section('content')
    @foreach($blocks->sortBy('order') as $block)
        {{  Blade::compileString($block->content) }}
    @endforeach
@endsection

I tried using {{ Blade::compileString($block->content) }} but that displays it as plain text. How can I make sure the blade syntax works?

Jan
02
4 months ago
Activity icon

Replied to Laravel - Change Language Using Ajax

@Nakov That does not work, unfortunately. but that also goes against the reason I wanted to use ajax in the first place

Activity icon

Started a new Conversation Laravel - Change Language Using Ajax

I want to change the language of my system using ajax. Currently, I have a dropdown and when the user selects a language, it automatically gets changed in the database. But when I use App::setLocale in the controller to change the actual language of the system. The language does not get updated. How can I accomplish this?

Form

<form method="POST" action="{{ route('change_language',['id' => Auth::user()->id]) }}" class="form-row my-3">
                    {{ csrf_field() }}
                    {{ method_field('PATCH') }}
                    <div class="form-group col-9">
                        <h4 class="mb-0">{{ __('Language') }}</h4>
                        <p class="m-0 sub-text">{{ __('Change the language of the dashboard') }}</p>
                    </div>
                    <div class="form-group col-3 d-flex justify-content-end align-items-center">
                        <select name="language" id="language" class="form-control">
                            <option value="nl" {{ ( Auth::user()->language == 'nl') ? 'selected' : '' }}>{{ __('Dutch') }}</option>
                            <option value="en" {{ ( Auth::user()->language == 'en') ? 'selected' : '' }}>{{ __('English') }}</option>
                        </select>

                    </div>
                    <div class="col-md-12 text-right">
                        <p class="text-success saved-message" style="display: none">{{ __('The language is changed!') }}</p>
                    </div>
                </form>

The ajax code

 $('#language').change(function() {
            $.ajax({
                headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
                url: '{{ route('change_language', ['id' => Auth::user()->id]) }}',
                type: 'PATCH',
                data: {"language": $(this).children("option:selected").val()},
                success: function(data) {
                    $('.saved-message').fadeIn();
                    setTimeout(function() {
                        $('.saved-message').fadeOut();
                    }, 1000);
                }
            })
        });

The controller code

public function changeLanguage(Request $request, $id)
    {
        $user = User::findOrFail($id);

        $user->language = $request->get('language');
        $user->save();
        
        App::setLocale($request->language);
    }

Route Route::patch('/dashboard/user/{id}/language', '[email protected]')->name('change_language');

Activity icon

Replied to Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

Hey @fylzero, First of all, Happy new year! I've run npm run dev and it compiles like normal with no error. The page that is listing the templates in the video has the layout backend.blade.php. This template has the id="app". Nowhere in my code do I have a deferred javascript tag. It is quite odd that it shows that error.

Jan
01
5 months ago
Activity icon

Replied to Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

Hey @fylzero, It did escape all the characters and put the whole layout in one line. but it did not change the error, unfortunately. I tried it with fopen, fwrite and fclose but the result is the same.

Edit:: I made a little video, maybe this clarifies things :https://www.youtube.com/watch?v=SvUBMIjl-2I&feature=youtu.be

Dec
31
5 months ago
Activity icon

Replied to Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

@fylzero Unfortunately html_enitity_decode does not work. I still have the same issue. What could it possibly be?

Activity icon

Replied to Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

The problem is. I know that the script needs to be placed at the bottom. I built a system where I can edit my layout files using my own UI. When I edit the file, the actual file within the layouts/layouts folder also gets updated. Normally when I move the script tag there is no problem and the error disappears. But when I move the script tag from a specific layout file (backend.blade.php) from the top to the bottom using my own UI. I get that massive error. While with other layout files there is no problem.

Activity icon

Replied to Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

As I stated in the post I already tried moving it to the bottom because I know it is bad practice to put them at the top but When I do it gives me that error. Thats the reason why I asked this question

Activity icon

Started a new Conversation Laravel - Unexpeted Token ">" While Trying To Compile Vue Template

I created a CMS in Laravel where I can create, edit and delete layout files. I accomplished this by creating files with the .blade.php extension, putting data into them and saving them in my layouts/layouts directory. I also store the names and content of the files in the database and whenever I change a row in the database, the file also gets updated. It all works like expected but I want to use Vue but In the console, there is the error

Cannot find element '#app'.

This issue can be fixed by moving the <script src="{{ asset('js/app.js') }}"></script> from the top of the file to the bottom. After I moved this line it works fine for all my views except for the view where I can edit the layout. The layout file where I just moved the script.

Personally I think the problem lays in the way I put the data back into the file after I updated it. This is the code that updates the file

public function update(Request $request, $id)
    {
        $layout = Layout::find($request->id);
        $file = resource_path('views/layouts/layouts/' . $layout->filename);
        file_put_contents($file, $request->content, FILE_IGNORE_NEW_LINES);
        $newName = resource_path('views/layouts/layouts/' . Str::camel($request->name) . ".blade.php");
        rename($file, $newName);

        $layout->name = $request->name;
        $layout->filename = Str::camel($request->name) . ".blade.php";
        $layout->content = $request->content;

        $layout->save();

        return redirect('/dashboard/layouts');
    }

These are the routes

Route::get('/dashboard/layouts', '[email protected]')->name('layouts');
Route::get('/dashboard/layout/create', '[email protected]')->name('create_layout');
Route::post('/dashboard/layout/store', '[email protected]')->name('store_layout');
Route::get('/dashboard/layout/{id}/edit', '[email protected]')->name('edit_layout');
Route::delete('/dashboard/layout/{id}/delete', '[email protected]')->name('delete_layout');
Route::patch('/dashboard/layout/{id}/update', '[email protected]')->name('update_layout');

This is the layout where the script needs to move from the top to the bottom. This file is called backend.blade.php

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>
    <script src="{{ asset('js/jquery-ui.js') }}"></script>
    <script src="{{ asset('js/Sortable.js') }}"></script>
    <script src="{{ asset('js/jquery-sortable.js') }}"></script>
    <script src="{{ asset('js/codemirror.js') }}"></script>
    <script src="{{ asset('js/main.js') }}"></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/all.min.css') }}" rel="stylesheet" >
    <link href="{{ asset('css/codemirror.css') }}" rel="stylesheet" >
    <link rel="stylesheet" href="{{ asset('css/styles.css') }}">
</head>
<body style="background: #ffffff">
<div class="">
    <nav class="sidebar">
        <ul class="list-unstyled">
            <li class="sidebar-item title">Information</li>
            <li class="sidebar-item"><a href="{{ route('home') }}" class="sidebar-link {{ Route::currentRouteNamed('home') ? 'sidebar-active' : '' }}">Dashboard</a></li>
            <li class="sidebar-item title">Content</li>
            <li class="sidebar-item"><a href="{{ route('pages') }}" class="sidebar-link {{ Route::currentRouteNamed('pages') ? 'sidebar-active' : '' }}">Pages</a></li>
            <li class="sidebar-item"><a href="{{ route('blocks') }}" class="sidebar-link {{ Route::currentRouteNamed('blocks') ? 'sidebar-active' : '' }}">Blocks</a></li>
            <li class="sidebar-item"><a href="{{ route('layouts') }}" class="sidebar-link {{ Route::currentRouteNamed('layouts') ? 'sidebar-active' : '' }}">Layouts</a></li>
            <li class="sidebar-item title">System</li>
            <li class="sidebar-item"><a href="{{ route('users') }}"  class="sidebar-link {{ Route::currentRouteNamed('users') ? 'sidebar-active' : '' }}">Users</a></li>
            <li class="sidebar-item"><a href="{{ route('roles') }}"  class="sidebar-link {{ Route::currentRouteNamed('roles') ? 'sidebar-active' : '' }}">Roles</a></li>
            <li class="sidebar-item title">Other</li>
            <li class="sidebar-item"><a href="">Preferences</a></li>
        </ul>
    </nav>

    <div class="dashboard-container">
      <div id="app">
          @yield('content')
      </div>
    </div>
</div>
</body>
</html>

I tried moving the script manually via a text editor (PHPStorm) instead of my own CMS but the result is the same. I get a massive error, In the error, you can see all the new lines (/n) and I tried fixing it with FILE_IGNORE_NEW_LINES as you can see in the code but unfortunately, it does not work.

The thing is, Whenever I move the line in another layout and not the backend.blade.php file using my CMS this error does not occur and the error of Cannot find #app does not display. Only when I edited the backend.blade.php file and try to re-edit it again that this error displays.

This is the edit.blade.php view

@extends('layouts.layouts.backend')

@section('content')
    <div class="container-fluid pt-5">
        <div class="row">
            <div class="col-md-12">
                <h3>Create new layout</h3>
            </div>
        </div>
        <div class="row my-5">
            <div class="col-md-6">
                <form method="POST" action="{{ route('update_layout', ['id' => $layout->id]) }}">
                    {{ csrf_field() }}
                    {{ method_field('PATCH') }}
                    <div class="form-group">
                        <label for="name">Name</label>
                        <input type="text" class="form-control" name="name" value="{{ $layout->name }}">
                    </div>
                    <div class="form-group">
                        <label for="content" class="content">Content</label>
                        <textarea name="content" id="" class="code-editor" cols="30" rows="10">{{ $layout->content }}</textarea>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Edit layout</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
@endsection

This is another layout file where the error does not occur when I move the line. This file is called app.blade.php

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="{{ asset('css/styles.css') }}">

</head>
<body style="background: #ffffff">
    <div id="">
        <nav class="navbar navbar-expand-md navbar-light bg-white">
            <div class="container">
                <a class="navbar-brand" href="{{ url('/') }}">
                    {{ config('app.name', 'Laravel') }}
                </a>
                <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>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->


                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item"><a class="nav-link" href="">About me</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Projects</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Services</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Experiences</a></li>
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            <div class="container mt-5" id="app">
                @yield('content')
            </div>
        </main>
    </div>

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

This is the full error message (It's long)

app.js:38033 [Vue warn]: Error compiling template:

invalid expression: Unexpected token '>' in

    "<!doctype html>\n<html lang=\""+_s(str_replace('_', '-', app()->getLocale()))+"\">\n<head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    <!-- CSRF Token -->\n    <meta name=\"csrf-token\" content=\""+_s(csrf_token())+"\">\n\n    <title>"+_s(config('app.name', 'Laravel'))+"</title>\n\n    <!-- Scripts -->\n    <script src=\""+_s(asset('js/app.js'))+"\" defer></script>\n\n    <!-- Fonts -->\n    <link rel=\"dns-prefetch\" href=\"//fonts.gstatic.com\">\n    <link href=\"https://fonts.googleapis.com/css?family=Nunito\" rel=\"stylesheet\">\n\n    <!-- Styles -->\n    <link href=\""+_s(asset('css/app.css'))+"\" rel=\"stylesheet\">\n    <link rel=\"stylesheet\" href=\""+_s(asset('css/styles.css'))+"\">\n\n</head>\n<body style=\"background: #ffffff\">\n    <div id=\"\">\n        <nav class=\"navbar navbar-expand-md navbar-light bg-white\">\n            <div class=\"container\">\n                <a class=\"navbar-brand\" href=\""+_s(url('/'))+"\">\n                    "+_s(config('app.name', 'Laravel'))+"\n                </a>\n                <button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#navbarSupportedContent\" aria-controls=\"navbarSupportedContent\" aria-expanded=\"false\" aria-label=\""+_s(__('Toggle navigation'))+"\">\n                    <span class=\"navbar-toggler-icon\"></span>\n                </button>\n\n                <div class=\"collapse navbar-collapse\" id=\"navbarSupportedContent\">\n                    <!-- Left Side Of Navbar -->\n\n\n                    <!-- Right Side Of Navbar -->\n                    <ul class=\"navbar-nav ml-auto\">\n                        <li class=\"nav-item\"><a class=\"nav-link\" href=\"\">About me</a></li>\n                        <li class=\"nav-item\"><a class=\"nav-link\" href=\"\">Projects</a></li>\n                        <li class=\"nav-item\"><a class=\"nav-link\" href=\"\">Services</a></li>\n                        <li class=\"nav-item\"><a class=\"nav-link\" href=\"\">Experiences</a></li>\n                    </ul>\n                </div>\n            </div>\n        </nav>\n\n        <main class=\"py-4\">\n            <div class=\"container mt-5\">\n                @yield('content')\n            </div>\n        </main>\n    </div>\n</body>\n</html>"

  Raw expression: <!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="{{ asset('css/styles.css') }}">

</head>
<body style="background: #ffffff">
    <div id="">
        <nav class="navbar navbar-expand-md navbar-light bg-white">
            <div class="container">
                <a class="navbar-brand" href="{{ url('/') }}">
                    {{ config('app.name', 'Laravel') }}
                </a>
                <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>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->


                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item"><a class="nav-link" href="">About me</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Projects</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Services</a></li>
                        <li class="nav-item"><a class="nav-link" href="">Experiences</a></li>
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            <div class="container mt-5">
                @yield('content')
            </div>
        </main>
    </div>
</body>
</html>


1  |  <div id="app">
   |  ^^^^^^^^^^^^^^
2  |                <div class="container-fluid pt-5">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3  |          <div class="row">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^
4  |              <div class="col-md-12">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5  |                  <h3>Create new layout</h3>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6  |              </div>
   |  ^^^^^^^^^^^^^^^^^^
7  |          </div>
   |  ^^^^^^^^^^^^^^
8  |          <div class="row my-5">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9  |              <div class="col-md-6">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 |                  <form method="POST" action="http://rainierlaan.test/dashboard/layout/3/update">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 |                      <input type="hidden" name="_token" value="MXEoSb44dBa3l3lmtipDT843j50vTOTGcjXsP7eq">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 |                      <input type="hidden" name="_method" value="PATCH">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 |                      <div class="form-group">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 |                          <label for="name">Name</label>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 |                          <input type="text" class="form-control" name="name" value="app">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 |                      </div>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
17 |                      <div class="form-group">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |                          <label for="content" class="content">Content</label>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |                          <textarea name="content" id="" class="code-editor" cols="30" rows="10">&lt;!doctype html&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |  &lt;html lang="{{ str_replace('_', '-', app()-&gt;getLocale()) }}"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |  &lt;head&gt;
   |  ^^^^^^^^^^^^
22 |      &lt;meta charset="utf-8"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23 |      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 |  
   |  
25 |      &lt;!-- CSRF Token --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26 |      &lt;meta name="csrf-token" content="{{ csrf_token() }}"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27 |  
   |  
28 |      &lt;title&gt;{{ config('app.name', 'Laravel') }}&lt;/title&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29 |  
   |  
30 |      &lt;!-- Scripts --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
31 |      &lt;script src="{{ asset('js/app.js') }}" defer&gt;&lt;/script&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32 |  
   |  
33 |      &lt;!-- Fonts --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^
34 |      &lt;link rel="dns-prefetch" href="//fonts.gstatic.com"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35 |      &lt;link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36 |  
   |  
37 |      &lt;!-- Styles --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^
38 |      &lt;link href="{{ asset('css/app.css') }}" rel="stylesheet"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39 |      &lt;link rel="stylesheet" href="{{ asset('css/styles.css') }}"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40 |  
   |  
41 |  &lt;/head&gt;
   |  ^^^^^^^^^^^^^
42 |  &lt;body style="background: #ffffff"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43 |      &lt;div id=""&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^
44 |          &lt;nav class="navbar navbar-expand-md navbar-light bg-white"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 |              &lt;div class="container"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46 |                  &lt;a class="navbar-brand" href="{{ url('/') }}"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47 |                      {{ config('app.name', 'Laravel') }}
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48 |                  &lt;/a&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
49 |                  &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50 |                      &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51 |                  &lt;/button&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52 |  
   |  
53 |                  &lt;div class="collapse navbar-collapse" id="navbarSupportedContent"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54 |                      &lt;!-- Left Side Of Navbar --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55 |  
   |  
56 |  
   |  
57 |                      &lt;!-- Right Side Of Navbar --&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58 |                      &lt;ul class="navbar-nav ml-auto"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59 |                          &lt;li class="nav-item"&gt;&lt;a class="nav-link" href=""&gt;About me&lt;/a&gt;&lt;/li&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 |                          &lt;li class="nav-item"&gt;&lt;a class="nav-link" href=""&gt;Projects&lt;/a&gt;&lt;/li&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 |                          &lt;li class="nav-item"&gt;&lt;a class="nav-link" href=""&gt;Services&lt;/a&gt;&lt;/li&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62 |                          &lt;li class="nav-item"&gt;&lt;a class="nav-link" href=""&gt;Experiences&lt;/a&gt;&lt;/li&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 |                      &lt;/ul&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64 |                  &lt;/div&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65 |              &lt;/div&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^
66 |          &lt;/nav&gt;
   |  ^^^^^^^^^^^^^^^^^^^^
67 |  
   |  
68 |          &lt;main class="py-4"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69 |              &lt;div class="container mt-5"&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70 |                  @yield('content')
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71 |              &lt;/div&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^^^^
72 |          &lt;/main&gt;
   |  ^^^^^^^^^^^^^^^^^^^^^
73 |      &lt;/div&gt;
   |  ^^^^^^^^^^^^^^^^
74 |  &lt;/body&gt;
   |  ^^^^^^^^^^^^^
75 |  &lt;/html&gt;</textarea>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^
76 |                      </div>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
77 |                      <div class="form-group">
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78 |                          <button type="submit" class="btn btn-primary">Edit layout</button>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79 |                      </div>
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
80 |                  </form>
   |  ^^^^^^^^^^^^^^^^^^^^^^^
81 |              </div>
   |  ^^^^^^^^^^^^^^^^^^
82 |  
   |  
83 |          </div>
   |  ^^^^^^^^^^^^^^
84 |      </div>
   |  ^^^^^^^^^^
85 |        </div>
   |  ^^^^^^^^^^^^

(found in <Root>)
warn @ app.js:38033
(anonymous) @ app.js:49101
compileToFunctions @ app.js:49100
./node_modules/vue/dist/vue.common.dev.js.Vue.$mount @ app.js:49324
Vue._init @ app.js:42411
Vue @ app.js:42477
./resources/js/app.js @ app.js:49478
__webpack_require__ @ app.js:20
0 @ app.js:49616
__webpack_require__ @ app.js:20
(anonymous) @ app.js:84
(anonymous) @ app.js:87
app.js:46463 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
app.js:10265 jQuery.Deferred exception: Cannot read property 'value' of undefined TypeError: Cannot read property 'value' of undefined
    at Function.fromTextArea (http://rainierlaan.test/js/codemirror.js:9639:30)
    at HTMLDocument.<anonymous> (http://rainierlaan.test/js/main.js:17:29)
    at mightThrow (http://rainierlaan.test/js/app.js:9981:29)
    at process (http://rainierlaan.test/js/app.js:10049:12) undefined
jQuery.Deferred.exceptionHook @ app.js:10265
process @ app.js:10053
setTimeout (async)
(anonymous) @ app.js:10087
fire @ app.js:9715
fireWith @ app.js:9845
fire @ app.js:9853
fire @ app.js:9715
fireWith @ app.js:9845
ready @ app.js:10325
completed @ app.js:10335
app.js:10274 Uncaught TypeError: Cannot read property 'value' of undefined
    at Function.fromTextArea (codemirror.js:9639)
    at HTMLDocument.<anonymous> (main.js:17)
    at mightThrow (app.js:9981)
    at process (app.js:10049)
fromTextArea @ codemirror.js:9639
(anonymous) @ main.js:17
mightThrow @ app.js:9981
process @ app.js:10049
setTimeout (async)
jQuery.readyException @ app.js:10273
(anonymous) @ app.js:10293
mightThrow @ app.js:9981
process @ app.js:10049
setTimeout (async)
(anonymous) @ app.js:10087
fire @ app.js:9715
fireWith @ app.js:9845
fire @ app.js:9853
fire @ app.js:9715
fireWith @ app.js:9845
process @ app.js:10069
setTimeout (async)
(anonymous) @ app.js:10087
fire @ app.js:9715
fireWith @ app.js:9845
fire @ app.js:9853
fire @ app.js:9715
fireWith @ app.js:9845
ready @ app.js:10325
completed @ app.js:10335

What causes this can how can it be fixed?

Dec
29
5 months ago
Activity icon

Replied to Laravel Custom Subpath, 404 Not Found

Hey @mstrauss thanks for your reply, All my routes except dashboard/pages don't work anymore and show a 404 Not Found. How does this work?

Nevermind I got it working by putting all my other routes above the rest. Thanks

Activity icon

Started a new Conversation Laravel Custom Subpath, 404 Not Found

I made a sort of mini CMS for my personal website. In this CMS you can add blocks to pages. You can also create a new page and add a parent page. It works like this:

Create a page called Projects

Create a page called Project 1 and add Projects as the parent page, making the URL like projects/project-1

Create a page called information and add Project 1 as the parent page, making the URL like projects/project-1/information

You get the idea. I already got the above part working but whenever I try to access a route that uses this generated URL, it says 404 Not Found.

My routes

Route::get('/{url}', '[email protected]')->name('show_page');
Route::get('/dashboard/pages', '[email protected]')->name('pages');
Route::get('/dashboard/page/create', '[email protected]')->name('create_page');
Route::post('/dashboard/page/store', '[email protected]')->name('store_page');
Route::get('/dashboard/page/{url}/edit', '[email protected]')->name('edit_page');
Route::delete('/dashboard/page/{url}/delete', '[email protected]roy')->name('delete_page');
Route::post('/dashboard/pages/order/{url}', '[email protected]')->name('change_order');

PageController.php In the create method I generate the URL like so

public function store(Request $request)
    {
        $identifier = str_replace(' ', '_', strtolower($request->name));
        if ($request->sub_page == 0) {
            $url = str_replace(' ', '-', strtolower($request->name));
        } else {
            $parent_page = Page::find($request->sub_page);
            $url = $parent_page->url . '/' . str_replace(' ', '-', strtolower($request->name));
        }


        $page = Page::create([
            'name' => $request->name,
            'identifier' => $identifier,
            'url' => $url,
            'status' => 1,
            'layout' => $request->layout,
            'page_id' => $request->sub_page,
            'created_at' => Carbon::now(),
            'updated_at' => Carbon::now()
        ]);

        return redirect('/dashboard/pages');
    }

Don't get confused with $identifier. That is something different and not related to the issue I create the view by doing:

public function show($id)
    {
        $page = Page::where('url', $id)->firstOrFail();
        $blocks = Block::where('page_id', $page->id)->where('status', 1)->get();

        return view('pages.show', compact('page', 'blocks'));
    }

How can this be fixed?

Dec
28
5 months ago
Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

I followed the exact steps and again with no luck. I turned off MySQL server and ran the command and proceeded to connect to my database but can't

[email protected] rainierlaan % sudo mysqld_safe --skip-grand-tables                                 
Logging to '/usr/local/mysql/data/MacBook-Pro-van-Rainier.local.err'.
2019-12-28T15:31:35.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2019-12-28T15:31:37.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/MacBook-Pro-van-Rainier.local.pid ended
[email protected] rainierlaan % mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[email protected] rainierlaan % mysql -u root root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[email protected] rainierlaan % 
Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

I did not stop any service? I just ran the command as it says on the website and that is my result.

Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

I did read the whole article and tried the steps but It does not the start mysql server. The commandline outputs this:

[email protected] rainierlaan % sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
[2] 61723
[email protected] rainierlaan % sudo: /usr/sbin/mysqld: command not found

[2]    exit 1     sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
[email protected] rainierlaan % 
Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

@nakov sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & does nothing

Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

@nakov I removed mysql by doing brew services stop mysql, brew unlink mysql and brew uninstall mysql and downloaded the .dmg file from Oracles website. Now whenever I want to do mysql -u root it says ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) and I can't connect anymore via the build-in database tool in PHPStorm while using the right password. which is rootroot. I updated my .env file and tried it all again but with no luck

Edit:: php artisan migrate now gives this:

Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = rainierlaan and table_name = migrations and table_type = 'BASE TABLE')
Activity icon

Replied to Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

Hey @Nakov, It shows the right port. The command is just stuck forever, I left it on for more than 2 hours and nothing. I tried changing it to localhost but no luck.

Activity icon

Started a new Conversation Laravel Valet MySQL - PHP Artisan Migrate Stuck, No Response

Recently I installed Laravel valet on my Mac. I want to use MySQL and went to the section "database" in the Laravel Valet documentation. There it says the following:

If you need a database, try MySQL by running brew install [email protected] on your command line. Once MySQL has been installed, you may start it using the brew services start [email protected] command. You can then connect to the database at 127.0.0.1 using the root username and an empty string for the password.

I followed the exact steps and made a connection via the build-in database tool in PHPStorm, which went fine. I looked at my .env file and it contains the right data

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=rainierlaan
DB_USERNAME=root
DB_PASSWORD=

I made a database called rainierlaan and ran php artisan migrate. But I get nothing in return and the command seems to be stuck.

What I have tried

  • Reinstalled MySQL by doing brew uninstall [email protected] and brew install [email protected]
  • Installed another MySQL version (8.0) which it is running on now.
  • Ran php artisan migrate -v. Same response, looks like the command is stuck.
  • Ran php artisan config:clear but has no effect
  • Ran composer dump-autoload but also seems to have no effect.
  • Checked with mysql -u root to see if the table rainierlaan exists, and it does.

How can this be solved?

Dec
25
5 months ago
Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

Yes valet links shows the correct site but in chrome it says the site is not reachable ERR_NAME_NOT_RESOLVED

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

I got it working. I can ping now but when I create a site it does not seem to work. I created a site called example and it should return a simple string when I access example.test in chrome. Instead it returns This site is not reachable

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

Read the stackoverflow link I've send. It has a more detailed explanation

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

None of the things suggested worked unfortunately. I created a stackoverflow thread with a more detailed explanation. see here https://stackoverflow.com/questions/59478336/laravel-valet-cannot-ping-unknown-host

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

valet links return no urls and I have removed the global package

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

I removed everything and started back from scratch with nothing. Followed every step in the right order and still have the original problem. I am running out of ideas to try

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

I fixed the issue but now I when I run composer global remove weprovide/valet-plus it says Installation failed, reverting ./composer.json to its original content.

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

I uninstalled everything related to valet. I removed all brew services such as nginx, dnsmasq, mysql etc. and tried to do valet install again. It gave me an error and did brew doctor. This says that there are broken symlinks found and I think that is the issue. It says I have to do brew cleanup but then It gives me the error Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

@nakov nginx is started see here https://imgur.com/a/FDRy9pl But it is not returning anything

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

@nakov Unfortunately, lsof -i tcp:80 does not return anything. Also, valet restart does not change anything. I added 127.0.0.1 to my DNS settings in System preferences > Network > Advanced > DNS hoping that will change anything but it does not. I did dig foobar.test but is does not show the ANSWER SECTION.

EDIT::

May it be the content of dnsmasq.conf at /etc/.valet/dnsmasq.conf?

Activity icon

Replied to Laravel Valet - Cannot Ping, "Unknown Host"

I Indeed had MAMP installed. I removed it and tried again. It still does not seem to work. I followed the videos @bugsysha said but it does not solve anything.

Dec
24
5 months ago
Activity icon

Started a new Conversation Laravel Valet - Cannot Ping, "Unknown Host"

I recently got a MacBook and want to use Valet. I followed all the steps on the Laravel website but I cannot ping. If I do ping foobar.test I get "Unknown host"... I have been trying to fix this issue for this entire day but can't seem to find the answer anywhere. Even If I go to the site that I created called example. Example.test should return an echo but instead, it says "This site is not reachable" in chrome.

I'm really beginning to lose my patience. I think it has something to do with dnsmasq but I just don't know what. I have tried the following things

  • Remove valet entirely and install it again
  • Remove all services independently and installed them all again
  • Reinstall Composer.

I just don't get the problem. Also when I upgrade the php version from 7.2 to 7.4 using brew update php and try to run valet. It says unlinked php. even though it is linked.... I just don't know what to do.

Edit:

I opened the console and looked for dnsmasq and I get the following error:

failed to create listening socket for 192.168.178.23: Permission denied

But all my brew services are run as root So i don't get why it says permission denied

Also, whenever I do dig foobar.test I see no answer section